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
Release history Release notifications | RSS feed
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
Hashes for pytest_forked-1.5.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe43952a8483d7e4dac3c3a6c4568095d5d35a42407c4e5c3f0917d2a038cafb |
|
MD5 | 64c4c465c8c44bfad739a459ebbfdd1f |
|
BLAKE2b-256 | 69868b2c57e67af19e8c1c01f9daf7b70ac25f0d9a298fb09f891945eb121876 |