You've used Mocker enough to see the repetitiveness involved in creating a mocking context at the beginning of the text and calling its
restore methods at the end. Mocker simplifies this for you by providing a class called
MockerTestCase in the mocker module.
MockerTestCase behaves just like a normal unittest
TestCase, except that for each test, it automatically creates a mocking context, which it then verifies and restores after the test. The mocking context is stored in
The following example demonstrates
MockerTestCase by using it to write a test involving a mock of
time.time. Before the test gets executed, a mocking context is stored in
self.mocker. After the test is run, the context is ...