There are three levels of setup and teardown available for the unittest modules. These define different kinds of testing scopes: method, class, and module, as follows:
- Test case setUp() and tearDown() methods: These methods ensure that each individual test method within a TestCase class has a proper context. Often, we'll use the setUp() method to create the units being tested and any mock objects that are required.
- Test case setUpClass() and tearDownClass() methods: These methods perform a one-time setup (and teardown) of all the tests in a TestCase class. These methods bracket the sequence of setUp()-testMethod()-tearDown() for each method. This can be a good place to insert and delete the data required by the test inside a database.
- Module setUpModule() and tearDownModule() functions: These two standalone functions provide us with a one-time setup...