Integration with test frameworks¶
Doubles includes plugins for automatic integration with popular test runners.
Pytest integration will automatically be loaded and activated via setuptools entry points. To disable Doubles for a particular test run, run Pytest as:
$ py.test -p no:doubles file_or_directory
Nose integration will be loaded and activated by running Nose as:
$ nosetests --with-doubles file_or_directory
Inherit from doubles.unittest.TestCase in your test case classes and the Doubles lifecycle will be managed automatically.
If you are using another test runner or need manual control of the Doubles lifecycle, these are the three methods you’ll need to use:
- doubles.verify should be called after each test to verify any expectations made. It can be skipped if the test case has already failed for another reason.
- doubles.teardown must be called after each test and after the call to doubles.verify.