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/master?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 from pip with:

python -m pip install pytest-super-check

Python 3.6 to 3.9 supported.


Testing a Django project? Check out my book Speed Up Your Django Tests which covers loads of best practices so you can 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.2.0.tar.gz (8.2 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.2.0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest-super-check-2.2.0.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.25.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.9.0

File hashes

Hashes for pytest-super-check-2.2.0.tar.gz
Algorithm Hash digest
SHA256 4e1725ac5e814a74c2fe782a83e5a87364deaf61347170b5cd814ffc1aab3fc8
MD5 78b4c2b114bd637573fa5487eb071112
BLAKE2b-256 5141b9f714d0e3539ccdb3d7d8356b08ddbe32faea649eb992d21951172c07df

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytest_super_check-2.2.0-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.25.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.9.0

File hashes

Hashes for pytest_super_check-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cea823eda8dd5247c5fcb1a237eb82c3a6f49c0137881a317f19f46c59632981
MD5 68127549a1ac4388db2a0dcc846d71db
BLAKE2b-256 18e55516363b7920fe8e81062d378535ac89e9f7a5a55875a24f0c39cb329e73

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