Using pytest and Tox

So far, all the tests we have written used ;unittest.TestCase classes and unittest.main() to run them. As your project grows, you will have more and more tests modules around.

To automatically discover and run all the tests in a project, the unittest package has 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's what inspired 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 ...

Get Python Microservices Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.