Pytest plugin to check your TestCase classes call super in setUp, tearDown, etc.
This project has been archived.
The maintainers of this project have marked this project as archived. No new releases are expected.
Project description
Pytest plugin to check your TestCase classes call super in setUp, tearDown, etc.
Features
This plugin checks all TestCase classes in your test suite to ensure that their setUp, tearDown, setUpClass, tearDownClass, and setUpTestData (Django extension) methods all call super(). You might care about this when you have extensions to these methods in your project specific base class that when skipped (by accidentally missing super()), cause subtle bugs.
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 some TestCase classes didn’t call super() in e.g. setUp, which caused the tests to fail, or incorrectly pass, in rather subtle ways. This problem is exacerbated by Django’s setUp etc. doing magic around not requiring super() to be called. Our solution was to just ensure every TestCase always calls super() in those methods. This is a Pytest port of that plugin.
Usage
Install from pip with:
pip install pytest-super-check
Python 3.4+ supported.
Pytest will automatically find and use the plugin. Test discovery will then blow up if any subclasses of unittest.TestCase are found that have setUp etc. methods that don’t call super().
You can disable the plugin by passing the options -p no:super_check to pytest.
Caveats
On Python 2, you’ll need to ensure any decorators you use on your setUp etc. methods set __wrapped__, to allow decorator-unwrapping so the inner source can be inspected. This is the default behaviour of functools.wraps on Python 3 so you’ll be more forwards compatible anyway.
History
Pending Release
2.0.0 (2019-02-28)
Drop Python 2 support, only Python 3.4+ is supported now.
1.0.0 (2016-04-22)
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytest-super-check-2.0.0.tar.gz.
File metadata
- Download URL: pytest-super-check-2.0.0.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/2.7.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20c7eaadbebeb029cfac6a2194be527effe1f4e9282313f589ccea6a6cca9b56
|
|
| MD5 |
c94116a12271c69b8c3c903233f84135
|
|
| BLAKE2b-256 |
f366860de77b7a83683bc1ffeb0f67fee903e7806c9009cde7e21be50a59d804
|
File details
Details for the file pytest_super_check-2.0.0-py3-none-any.whl.
File metadata
- Download URL: pytest_super_check-2.0.0-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/2.7.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7f285d70cafd1299b70debcaf885caef4d3768aa6c5ee76e10b86ab2a6cf740
|
|
| MD5 |
ed893e5c27cf5d3d854235f6be1f791b
|
|
| BLAKE2b-256 |
22ec66ed0b35464509ce66023143cf7a2788467d3774eba4644b8233249380ca
|