Tools for testing
There are a lot of tools we can use for writing our unit tests, all of them with pros and cons and serving different purposes. I'll present the two most common libraries used for unit testing in Python. They cover most (if not all) use cases, and they're very popular, so knowing how to use them comes in handy.
Along with testing frameworks and test running libraries, it's often common to find projects that configure code coverage, which they use as quality metrics. Since coverage (when used as a metric) is misleading, after seeing how to create unit tests, we'll discuss why it's not to be taken lightly.
The next section starts by introducing the main libraries we're going to use in this chapter for unit testing.
Frameworks and libraries for unit testing
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...