An alternative to the unittest runner is the pytest test runner. The pytest framework has an excellent test discovery feature that goes beyond what the unittest tool can discover.
The unittest runner can be used in the following two ways.
- With a test suite object. The previous examples have focused on this.
- To search for classes that are extensions of unittest.TestCase, build a test suite from those, and then run the suite. This offers considerable flexibility. We can add test cases without also having to update the code to build the test suite.
The pytest tool can also locate unittest.TestCase class definitions, build a suite of tests, and execute the tests. It can go beyond this and also locate functions with names starting with test_ in modules where the name starts with test_. Using simple functions has some advantages over the more complex unittest...