XRPLF / xrpl-py

A Python library to interact with the XRP Ledger (XRPL) blockchain
ISC License
144 stars 83 forks source link

tests: check exception messages correctly #703

Closed ckeshava closed 2 days ago

ckeshava commented 1 month ago

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 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.

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