In this section, we will discuss two frameworks for writing and running unit tests. The first one, unittest, is available in the standard library of Python, while the second one, pytest, has to be installed externally via pip.
- unittest: https://docs.python.org/3/library/unittest.html
- pytest: https://docs.pytest.org/en/latest/
When it comes to covering testing scenarios for our code, unittest alone will most likely suffice, since it has plenty of helpers. However, for more complex systems on which we have multiple dependencies, connections to external systems, and probably the need to patch objects, and define fixtures parameterize test cases, then pytest looks like a more complete option.
We will ...