Pytest plugin to restrict the test types allowed
Project description
Pytest plugin to restrict the test types allowed.
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 list of import strings to allowable test case base classes, for example:
# Allow only test cases that inherit from Django
py.test --restrict-types django.test.TestCase django.test.SimpleTestCase
If you wish to allow function tests and other non-class test types (e.g. doctests), provide the special string ‘None’, for example:
# Allow function tests and our custom tests
py.test --restrict-types None myproject.test.TestCase
History
Pending Release
New release notes here
First release on PyPI
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pytest_restrict-1.0.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d2cbdcdadf29159f136a9c81ad7841d864b44305b4c2ed4910d4210bcb113b3 |
|
MD5 | 5e493692d7d25b61cc41ee43954a40c5 |
|
BLAKE2b-256 | c3d3cf5f1f1699e798a13955f3cb670f9449556c89948ae328cbdbaaaeb5c46f |