Skip to main content

pytest-bisect-tests

Sometimes one test can affect the execution of another test. This simple script tries to find the offender.

This script can be called as standalone script, or via pytest option.

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

Comparison of UX

Standalone script: asciicast

pytest option: asciicast

Installation

$ pip install pytest-bisect-tests

Usage

Standalone script

$ 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.

As pytest option

This approach automatically discovers all tests in the suite and failing test, so it has minimal input options.

$ pytest --bisect-first-failure

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).

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-bisect-tests-0.2.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_bisect_tests-0.2.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file pytest-bisect-tests-0.2.0.tar.gz.

File metadata

  • Download URL: pytest-bisect-tests-0.2.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.12

File hashes

Hashes for pytest-bisect-tests-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e5a6da20b5f12945374ff62de864a6394e3ead9761f7f7d94c08ebded942341a
MD5 4b47913bf37616565ccba8e12eadece3
BLAKE2b-256 f012cefa39fde32d4de6934b5e0b157199d77832ee8def51c8a1434b45a1af5f

See more details on using hashes here.

File details

Details for the file pytest_bisect_tests-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_bisect_tests-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f9f41b13578d0aa87b1693c73cfbc0fc531ab62baa9e4ad82064a3d530cfb9fd
MD5 1f53425e8c0e141bb20457cb4ecc0103
BLAKE2b-256 f740c56d760946db8944945304af3ae27c759911e1f8f8f662fb81b0bf8d1c3b

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.0

2 files

This release

0.2.0 This release

2 files

0.1.0

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 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