Skip to main content

Pytest plugin to check your TestCase classes call super in setUp, tearDown, etc.

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

Unmaintained (2022-12-07)

I stopped maintaining this package as it has never been popular. I think it would be better to use a lint rule to enforce calling super() in test cases.


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.1.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

pytest_super_check-2.6.1-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pytest-super-check-2.6.1.tar.gz
Algorithm Hash digest
SHA256 3e2704a79c11399c6f50457751d6eda973ba35f5e408451c59a8bfd529545d1f
MD5 f57f1f1a16ac9ef00e11b36fd45a2130
BLAKE2b-256 deeb89c141363d567b97851039063ee1b70f0ac4d97103aa7e044fb020279c94

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytest_super_check-2.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3de007907a4da84732bdc5a19e01d50346105c98d89fd36184b743f5b48b77ca
MD5 e0d0447da1a3c5745c1494b49cfbb061
BLAKE2b-256 fc9c4472491d48e7bf4698dcc41480db36ed51fcdaf4af634f740f0781d42d69

See more details on using hashes here.

Supported by

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