Using pytest and tox
So far, all the tests we have written use unittest
classes and unittest.main()
to run them. As your project grows, you will have more and more test modules around.
To automatically discover and run all the tests in a project, the unittest
package introduced a Test Discovery feature in Python 3.2, which finds and runs tests, given a few options. This feature has been around for a while in projects like Nose (https://nose.readthedocs.io) and pytest, and that was what inspired the test discovery feature in the unittest
package in the standard library.
Which runner to use is a matter of taste, and as long as you stick to writing your tests in TestCase
classes, your tests will be compatible with all of them.
That said, the pytest project is very popular in the Python community, and since it offers extensions, people have started to write useful tools around it. Its runner is also quite efficient, as it starts to run the tests while they are still discovered...