When we capture the exception object in the subclasses of unittest.TestCase, we are not correctly validating test conditions. After the specified exception is raised, none of the self.assertEqual statements are evaluated inside the scope of the self.assertRaises context manager. The print() statements are also not evaluated within that scope.
High Level Overview of Change
When we capture the exception object in the subclasses of
unittest.TestCase
, we are not correctly validating test conditions. After the specified exception is raised, none of theself.assertEqual
statements are evaluated inside the scope of theself.assertRaises
context manager. Theprint()
statements are also not evaluated within that scope.Here's an example: https://github.com/XRPLF/xrpl-py/commit/abc3b0cff17a9a1566d531c3a94511ccbfa702f6 ^^ In the above example, I intentionally test contradictory statements to demonstrate that the tests are not working.
I wish the python standard library/the interpreter handled this case better. If I'm missing something, please point me to the docs.
Reference docs: https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertRaises
Context of Change
Type of Change
Did you update CHANGELOG.md?
Test Plan