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/github/workflow/status/adamchainz/pytest-super-check/CI/main?style=for-the-badge https://img.shields.io/pypi/v/pytest-super-check.svg?style=for-the-badge https://img.shields.io/badge/code%20style-black-000000.svg?style=for-the-badge pre-commit

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.

Installation

Install with:

python -m pip install pytest-super-check

Python 3.7 to 3.11 supported.


Testing a Django project? Check out my book Speed Up Your Django Tests which covers loads of ways to write faster, more accurate tests.


Usage

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.

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-2.6.0.tar.gz (5.4 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-2.6.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest-super-check-2.6.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for pytest-super-check-2.6.0.tar.gz
Algorithm Hash digest
SHA256 67e26b00e86a8fe8258ec34dbc6ea3330c7bea4ee3115db721150d29a3e611c9
MD5 72653c0a74764d57dff639c067f2b1b9
BLAKE2b-256 9476d859869c37fa0337e8ec8330a641b4d14656090f18f9df0cffa316e17263

See more details on using hashes here.

File details

Details for the file pytest_super_check-2.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_super_check-2.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bca70fd76c37c023e71af51341c0713c532304f868cf4dd5551badf1387c762b
MD5 5083409d0f1ee19d3084c5d552414288
BLAKE2b-256 a210d41de38b61fcfaa51f4e0ba16ab07af87f7c31afa82af506d4ddba9e9428

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