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.
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
Built Distribution
File details
Details for the file pytest_cleanslate-1.0.3.tar.gz
.
File metadata
- Download URL: pytest_cleanslate-1.0.3.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0dfb0e7f4efba96b021c2e05e429377a3bca7350c4568cd33ed271bdd09f8dc |
|
MD5 | bf8f9cd9c93fb0f941e8437b6fd02735 |
|
BLAKE2b-256 | d8c99205452bb519b9556e1c32450b57880d6441ef095ff6498cfdca44ec62cc |
File details
Details for the file pytest_cleanslate-1.0.3-py3-none-any.whl
.
File metadata
- Download URL: pytest_cleanslate-1.0.3-py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4da11bfa67beee577437ca98ebfc65d1dedf28b0dbf0b584a97e223f787bc243 |
|
MD5 | 31d2b1b0b53ddc7775186fd3b06b42ce |
|
BLAKE2b-256 | 0c13068d54b03eb4694bfa5b92ec46bb2d4285b3068c17e8aa0831bbfdcb52e2 |