Find tests leaking state and affecting other
Project description
pytest-bisect-tests
Sometimes one test can affect the execution of another test. This simple script tries to find the offender.
Example:
# faulty_test.py
a = 1
def test_faulty() -> None:
global a
a = 2
def test_failing() -> None:
assert a == 1
$ pytest-bisect-tests --failing-test "faulty_test.py::test_failing"
Checking if the test fails on its own.
Running 1 tests.
Trying to find the faulty test.
Running 2 tests.
Faulty test: faulty_test.py::test_faulty
Installation
$ pip install pytest-bisect-tests
Usage
$ pytest-bisect-tests --failing-test "<identifier of the test as pytest shows them with -v>"
Additional arguments:
$ pytest-bisect-tests --help
usage: pytest-bisect-tests [-h] --failing-test FAILING_TEST [--run-options RUN_OPTIONS] [--collect-options COLLECT_OPTIONS] [--stdout]
options:
-h, --help show this help message and exit
--failing-test FAILING_TEST
REQUIRED. The identifier of the test, as shown by pytest -v.
--run-options RUN_OPTIONS
Arguments that will be passed directly to pytest. A single string.
--collect-options COLLECT_OPTIONS
Arguments that will be passed to pytest during tests collection. A single string.
This is useful when, for example, you have a test grouping plugin that affects the tests run.
--stdout If passed, pytest output will be shown.
Alternatives
detect-test-pollution, an alternative package with similar functionality. Lacks passing pytest run and collect options or showing the output from pytest. It also doesn't support pytest plugins that alter how tests are collected (like pytest-test-groups).
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
Close
Hashes for pytest-bisect-tests-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | eff4c7ea745734f98c091b48bae52cac2291884d8600d0c457f8704b7f40cd6a |
|
MD5 | 7f487338964feb03261ea46574975fee |
|
BLAKE2b-256 | 5c3b56454a209915a34927a3d0359fd064301c0b4c42156138b6d70091001626 |
Close
Hashes for pytest_bisect_tests-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d90396a664c3219608d583054d018a72892e82336196b1131e69e147cf4ff5d7 |
|
MD5 | a69e2a59e682914b6a80360efbb60f4f |
|
BLAKE2b-256 | bbcbe1f2b0f3f923e8a61ea27e9fa5f9c738f60ef5765c0f9b5c91f322333f27 |