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.

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

Uploaded Source

Built Distribution

pytest_forked-1.3.0-py2.py3-none-any.whl (4.7 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: pytest-forked-1.3.0.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.0

File hashes

Hashes for pytest-forked-1.3.0.tar.gz
Algorithm Hash digest
SHA256 6aa9ac7e00ad1a539c41bec6d21011332de671e938c7637378ec9710204e37ca
MD5 7de04c46b48ca5c5a24e45bf1546355f
BLAKE2b-256 62922d418d7b0c9d68a2e885b66d7f6805f9678ce56ad2b3a77669437b2d139a

See more details on using hashes here.

File details

Details for the file pytest_forked-1.3.0-py2.py3-none-any.whl.

File metadata

  • Download URL: pytest_forked-1.3.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.0

File hashes

Hashes for pytest_forked-1.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 dc4147784048e70ef5d437951728825a131b81714b398d5d52f17c7c144d8815
MD5 3bf024234f619cbea87b7c93388c910c
BLAKE2b-256 9d8877eeb091b4fa79f28c08718f6e6ebff5827d9d1c1dd9974218ddfbe031ee

See more details on using hashes here.

Supported by

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