Skip to main content

run tests in isolated forked subprocesses

Project description

This plugin does not work on Windows because there’s no fork support.

  • --forked: run each test in a forked subprocess to survive SEGFAULTS or otherwise dying processes.

python version ci pre-commit black

Installation

Install the plugin with:

pip install pytest-forked

or use the package in develope/in-place mode with a checkout of the pytest-forked repository

pip install -e .

Usage examples

If you have tests involving C or C++ libraries you might have to deal with tests crashing the process. For this case you may use the boxing options:

pytest --forked

which will run each test in a subprocess and will report if a test crashed the process. You can also combine this option with running multiple processes via pytest-xdist to speed up the test run and use your CPU cores:

pytest -n3 --forked

this would run 3 testing subprocesses in parallel which each create new forked subprocesses for each test.

You can also fork for individual tests:

@pytest.mark.forked
def test_with_leaky_state():
    run_some_monkey_patches()

This test will be unconditionally boxed, regardless of CLI flag.

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-forked-1.4.0.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

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

pytest_forked-1.4.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file pytest-forked-1.4.0.tar.gz.

File metadata

  • Download URL: pytest-forked-1.4.0.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for pytest-forked-1.4.0.tar.gz
Algorithm Hash digest
SHA256 8b67587c8f98cbbadfdd804539ed5455b6ed03802203485dd2f53c1422d7440e
MD5 fc2d4bb78f3a5e7c082173527d5009d3
BLAKE2b-256 f1bc0121a2e386b261b69f4f5aa48e5304c947451dce70d68628cb28d5cd0d28

See more details on using hashes here.

File details

Details for the file pytest_forked-1.4.0-py3-none-any.whl.

File metadata

  • Download URL: pytest_forked-1.4.0-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for pytest_forked-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bbbb6717efc886b9d64537b41fb1497cfaf3c9601276be8da2cccfea5a3c8ad8
MD5 bf0249039fb39cb7d6af60f09957e61d
BLAKE2b-256 0c36c56ef2aea73912190cdbcc39aaa860db8c07c1a5ce8566994ec9425453db

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page