We'll build a test module with a module-level fixture. In the fixture, we'll replace the
datetime.date.today function, which normally returns an object representing the current date. We want it to return a specific value, so that our tests can know what to expect.
tests. We'll use this directory in this Time for action, as well as in the next one.
testsdirectory, create a file called
module_fixture_tests.pycontaining the following code:
from unittest import TestCase from mocker import Mocker from datetime import date mocker = Mocker() def setup(): fake_date = mocker.replace(date) fake_date.today() mocker.result(date(year = 2009, month = 6, day = 12)) mocker.count(1, ...