requests / requests-oauthlib

OAuthlib support for Python-Requests!
https://requests-oauthlib.readthedocs.org/
ISC License
1.72k stars 424 forks source link

Use more specific asserts #354

Closed jdufresne closed 5 years ago

jdufresne commented 5 years ago

More specific asserts generally result in more informative error messages when tests fail. This practice is recommended by the unittest docs:

https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertTrue

This method should also be avoided when more specific methods are available (e.g. assertEqual(a, b) instead of assertTrue(a == b)), because they provide a better error message in case of failure.

Replace assertTrue(isinstance(...)) with assertIsInstance.

Additionally, replace truthiness checks with precise True/False checks. This practice is also recommended by the unittest docs:

assertTrue

Note that this is equivalent to bool(expr) is True and not to expr is True (use assertIs(expr, True) for the latter).

Replace assertTrue(...) with assertIs(..., True).

coveralls commented 5 years ago

Coverage Status

Coverage remained the same at 88.025% when pulling 1dc93459a4c2fd76cc60a43aad4c2615d0cb29d7 on jdufresne:assertisinstance into 5aa60bf074c8eb30aea42da26b7ebbf97a72053a on requests:master.

coveralls commented 5 years ago

Coverage Status

Coverage remained the same at 88.025% when pulling 33f9a56b136b6b5ae06f913613915fe466b3f7f5 on jdufresne:assertisinstance into 364762ebd1ceceaa63c298311cbd25a3db204680 on requests:master.