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.6.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

pytest_cleanslate-1.0.6-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pytest_cleanslate-1.0.6.tar.gz
Algorithm Hash digest
SHA256 dc8df97039b9d2df756e5885969aadac736f7a1a151ecc0559e7d59a23ec5b6b
MD5 84e5d003210fa9574f25220cdb64506f
BLAKE2b-256 dae4f8a6a70692a15b1ea7a4a0e8b4ad1632b36ea30defc95f886ba01ddbdc86

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytest_cleanslate-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 621f3a2450ce8d17429d513cadb33c39488b064d41506c277a858915ba345dda
MD5 cfafd5015ef3bb70356e1c8660d4107b
BLAKE2b-256 76b2a096072b677518ce5feb1083dcd87ebad7b65f3287b8b6fbb248c988763d

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