A test stops execution once it hits a failing assert statement.
That’s kinda the point of an assert statement, though, so that’s not surprising.
However, sometimes it’s useful to continue with the test even with a failing assert.
I’m going to present one method for getting around this restriction, to test multiple things, allow multiple failures per test, and continue execution after a failure.
I’m not really going to describe the code in detail, but I will give the full source so that you can take it and run with it.
- Reasons for multiple assert statements and not stop execution
- Using a failure list to keep track of failures within a test
- Example test code that uses the delayedAssert module
- And an example for unittest
- The output for unittest
- The output for pytest
- The output for nose
- The delayedAssert.py module
- Feedback welcome