Skip to main content

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.

Metadata

Release files for pytest-cleanslate 1.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-cleanslate 1.0.5
File Size Uploaded
pytest_cleanslate-1.0.5.tar.gz 16.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-cleanslate 1.0.5
File Interpreter ABI Platform
pytest_cleanslate-1.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 29.5 kB

Release files / pytest_cleanslate-1.0.5.tar.gz

Download URL pytest_cleanslate-1.0.5.tar.gz
Size 16.3 kB
Tags Source
SHA-256 checksum
How to use checksums
c1df3a429b0d2e04bd81080e9dfa38ad3f4bc81f8ce5f2f0691cbc86c910c0f2
BLAKE2b-256 checksum
How to use checksums
e6b6b1c9c20ae822f7891334bc4c22f9385244c9ab7b206e5b4c0df0f95d5d73
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.11.9

Release files / pytest_cleanslate-1.0.5-py3-none-any.whl

Download URL pytest_cleanslate-1.0.5-py3-none-any.whl
Size 13.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
88ff4cb179a5bd11f20796dbe73ede0e3303f4814180e83c7780c52a87c77ad5
BLAKE2b-256 checksum
How to use checksums
6184a9d530a22cad103e72f7097e76341bd742318e1e7d019ee4a06d223c04be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.11.9

Release history Release notifications | RSS feed

1.0.7

2 release files

1.0.6

2 release files

This release

1.0.5 This release

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page