Skip to main content

Collects and executes pytest tests separately

Project description

pytest-cleanslate: work around or find test state pollution

by Juan Altmayer Pizzorno and Emery Berger at UMass Amherst's PLASMA lab.

license pypi pyversions tests Downloads

About

pytest-cleanslate is a small plugin for the pytest test framework which, as the name implies, helps give each test module a "clean slate" to execute. Plugins such as pytest-forked and pytest-isolate allow you to execute tests in separate processes, working around in-memory test "state pollution" resulting from their execution, but do not protect against pollution caused by top-level code in test modules; this is what pytest-cleanslate remedies.

This module also includes cleanslate-reduce, a tool for finding where the state pollution is occurring. Invoked on a test suite with a failing test, cleanslate-reduce looks for a smaller set of test modules and functions that still lead to the test failure.

How to use

After pip install pytest-cleanslate, simply add --cleanslate to your pytest command line (or configuration options).

Interaction with other plugins

Running with --cleanslate also makes use of pytest-forked, i.e., it is as though you installed that plugin and passed in --forked to execute all tests in separate processes.

It also subverts somewhat pytest's mode of operation in that it postpones collecting test items within test modules (i.e., within Python test files) until the test execution phase. While we have attempted to stay as compatible with other plugins as possible, it is likely to not work in some combinations (such as, for example, pytest-xdist). Feel free to open an issue if you come across a case where it doesn't work.

Requirements

Python 3.8+, Linux or MacOS.

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_cleanslate-1.0.5.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

pytest_cleanslate-1.0.5-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file pytest_cleanslate-1.0.5.tar.gz.

File metadata

  • Download URL: pytest_cleanslate-1.0.5.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.9

File hashes

Hashes for pytest_cleanslate-1.0.5.tar.gz
Algorithm Hash digest
SHA256 c1df3a429b0d2e04bd81080e9dfa38ad3f4bc81f8ce5f2f0691cbc86c910c0f2
MD5 3435d798126633085757f950b3a63e7a
BLAKE2b-256 e6b6b1c9c20ae822f7891334bc4c22f9385244c9ab7b206e5b4c0df0f95d5d73

See more details on using hashes here.

File details

Details for the file pytest_cleanslate-1.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_cleanslate-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 88ff4cb179a5bd11f20796dbe73ede0e3303f4814180e83c7780c52a87c77ad5
MD5 a395053c4a066a92d401408842c485f4
BLAKE2b-256 6184a9d530a22cad103e72f7097e76341bd742318e1e7d019ee4a06d223c04be

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