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.10 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.5.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.5.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest-super-check-2.5.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

File hashes

Hashes for pytest-super-check-2.5.0.tar.gz
Algorithm Hash digest
SHA256 43e6339db02807d97e3d82c071e4aea7654ea3bd11aa4970134984d737d2611a
MD5 c477ef9b2a05416b2dd5ea70cafea7c5
BLAKE2b-256 ca878709eb8a50e110a0122fee2a4d0d4fdbff9472103660b08162d6c7c51ab8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytest_super_check-2.5.0-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

File hashes

Hashes for pytest_super_check-2.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f3a60920d0c656fb648d89155a04724c84b73c4cd3afc6d6134385fb59ecbb6e
MD5 1604634b6f49481e7b262be4a9b3ef15
BLAKE2b-256 00d30059f0ed71323c34b9c2ecc554cace944bef88a911095c3dd9c3bda8cc8a

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