Features

This plugin allows you to restrict the test types allowed to ensure they
inherit from one of a given list of classes. You might need this on large
projects where you have custom test classes that developers might forget about.

About

I developed this feature in a closed source Nose plugin whilst working on the
big Django project at YPlan. We had some custom enhancements and fixes on top
of the Django test classes, but developers sometimes forgot about using them
and instead used the built-in unittest classes, or the plain Django ones.
Our solution was to just make the test runner blow up if it encountered
non-whitelisted test types. This is a Pytest port of that plugin.

Usage

Install from pip with:

pip install pytest-restrict

Pytest will automatically find the plugin and use it when you run py.test,
however by default there are no restrictions. To restrict the test types,
provide --restrict-types as a comma-separated list of import paths to
allowable test case base classes, for example:

History

Pending Release

New release notes here

2.0.0 (2016-04-29)

Changed the format of --restrict-types to take a comma-separated list of
import paths rather than space separated, which fixes the parsing of e.g.
py.test --restrict-types my.TestCase run/these/test_files.py.