In this section, we're going to look at Python's standard unittest package. We'll talk about how to structure a test file and how to write tests and draw a comparison between what happens and what should happen in these tests. Let's jump straight into it!
Using the unittest package
Structuring a test file
The unittest module contains a framework for performing automated unit testing. Most of this functionality is based around the unittest.TestCase class, which we will inherit from to create our own tests.
In the following example, we see the basic features of TestCase in action and also test and assert methods:
Any method that we define using a class inherited from TestCase, and that has a name that starts...