Skip to main content

Pytest plugin to reverse test order.

Project description

https://img.shields.io/github/workflow/status/adamchainz/pytest-reverse/CI/master?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.

Installation

Install from pip with:

python -m pip install pytest-reverse

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 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.

Files for pytest-reverse, version 1.1.1
Filename, size File type Python version Upload date Hashes
Filename, size pytest_reverse-1.1.1-py3-none-any.whl (3.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size pytest-reverse-1.1.1.tar.gz (5.9 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page