Skip to main content

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

https://img.shields.io/travis/adamchainz/pytest-super-check.svg https://img.shields.io/pypi/v/pytest-super-check.svg

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

Pytest will automatically find the plugin and use it when you run py.test. 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 py.test.

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

  • New release notes here

1.0.0 (2016-04-22)

  • First release on PyPI

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-super-check-1.0.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_super_check-1.0.0-py2.py3-none-any.whl (5.8 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pytest-super-check-1.0.0.tar.gz.

File metadata

File hashes

Hashes for pytest-super-check-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1abbe9183e43debad4a723c1a7404289d841a41036d2448e8f05aa0fb05739f3
MD5 d80c301a1326bb401243d70c8555eb5b
BLAKE2b-256 8eedae58aad2c515358a8838d337e590d9f996538df21ac9be5d99fe7b643089

See more details on using hashes here.

File details

Details for the file pytest_super_check-1.0.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_super_check-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 67a0487a135cb2861fc695bf635246668eb31909f849e639076534ff2eb82efa
MD5 a0c79b10d8d14bd906e6b645d25e5788
BLAKE2b-256 aa7f9a77fd37455e054346a08aebbc1936a8af9333573f2d6a4ed3e544cd7e76

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page