Skip to main content

Pytest plugin to reverse test order.

Project description

https://img.shields.io/github/actions/workflow/status/adamchainz/pytest-reverse/main.yml.svg?branch=main&style=for-the-badge https://img.shields.io/pypi/v/pytest-reverse.svg?style=for-the-badge https://img.shields.io/badge/code%20style-black-000000.svg?style=for-the-badge pre-commit

Pytest plugin to reverse test order.


Testing a Django project? Check out my book Speed Up Your Django Tests which covers loads of recommendations to write faster, more accurate tests. I created pytest-reverse whilst working on the book!


Installation

Install with:

python -m pip install pytest-reverse

Python 3.9 to 3.14 supported.

Usage

Pytest will automatically find the plugin and use it when you run pytest. You can reverse test order by passing the --reverse flag:

pytest --reverse

You can make this always apply by adding it to the addopts setting in your pytest.ini (or other configuration file):

[pytest]
addopts = --reverse

History

I’m the creator and maintainer of pytest-randomly, a plugin for randomly ordering tests. @thbde opened an issue there pointing to the paper Empirically revisiting the test independence assumption, which covers test reordering techniques. It turns out that reversal is nearly as effective as randomization.

Test reversal is available in Django’s test runner. I figured such an option or plugin would exist for pytest already, but it didn’t, so I made it here.

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_reverse-1.9.0.tar.gz (4.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_reverse-1.9.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file pytest_reverse-1.9.0.tar.gz.

File metadata

  • Download URL: pytest_reverse-1.9.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pytest_reverse-1.9.0.tar.gz
Algorithm Hash digest
SHA256 a3b756f13bfc5b9aa39bfc57d2d5e03ec62f7fdfed2c04cad664c283d63ce94a
MD5 0c3c4b1216283fb2c9a010232e073095
BLAKE2b-256 d05f9f3227f0c1ae1411fa5921af8f9cb88ac71f988750ab0bc27f4a29179a64

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_reverse-1.9.0.tar.gz:

Publisher: main.yml on adamchainz/pytest-reverse

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytest_reverse-1.9.0-py3-none-any.whl.

File metadata

  • Download URL: pytest_reverse-1.9.0-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pytest_reverse-1.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3cb9cb2403eea2f953fd6b9629637387cf6e75594f8573738f68ec1aca11dcd1
MD5 56671883263db1d3291369a4c860b73a
BLAKE2b-256 291c126e8d934e8852c89fb898f77512050c0c34cf96f195f02cbd36c5dd0356

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_reverse-1.9.0-py3-none-any.whl:

Publisher: main.yml on adamchainz/pytest-reverse

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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