pytest-forked
run tests in isolated forked subprocesses
Decision gist · record as of 2026-08-14
Yes, if you test C/C++ libraries or crash-prone code on POSIX systems. The low install friction and active maintenance make it a straightforward addition to test suites that need crash isolation. Not applicable on Windows. The inactive status means minimal new features, but the core functionality is stable and the plugin remains functional.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Does not work on Windows; requires a POSIX system with fork() support (Linux, macOS).
- Requires Python 3.10 or later.
- Low friction install with a single runtime dependency on pytest.
License · maintenance · safety
MIT (permissive) — MIT license permits commercial and private use with minimal restrictions; suitable for most projects.
last release 2026-08-08 (6 days) · last repo commit 2026-08-08 · 81 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 7,263,193 downloads/mo, #1,761 on PyPI
Alternatives
Verify before relying
pip install pytest-forked
pytest --forked
# Or mark individual tests:
@pytest.mark.forked
def test_with_leaky_state():
pass- Whether the plugin works correctly with pytest-xdist in all configurations beyond the documented -n3 --forked example.
- Performance overhead of forking per test compared to in-process execution.
What it is and what it does
pytest-forked is a pytest plugin that isolates each test by running it in a forked subprocess. This allows tests involving C or C++ libraries—or any code prone to crashing—to fail gracefully without terminating the entire test run. A segfault or process death in one test does not affect subsequent tests.
The plugin is extracted from pytest-xdist's --forked module and can be used standalone with the --forked CLI flag, applied per-test via the @pytest.mark.forked decorator, or combined with pytest-xdist's parallel execution (e.g., pytest -n3 --forked) to run multiple test subprocesses in parallel, each forking individual tests. It is not available on Windows due to the absence of fork() support.
Use it for
- Testing C/C++ bindings or extension modules that may crash the Python interpreter.
- Running tests with monkey-patched global state that could leak between tests.
- Detecting and reporting segfaults as test failures rather than suite termination.
- Combining with pytest-xdist to parallelize tests while isolating crash-prone code.
- Validating cleanup and teardown in tests that modify process-level state.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you test C/C++ libraries or crash-prone code on POSIX systems.
The low install friction and active maintenance make it a straightforward addition to test suites that need crash isolation. Not applicable on Windows. The inactive status means minimal new features, but the core functionality is stable and the plugin remains functional.
Install
pytest-forked on PyPI
Before you install
Low friction install with a single runtime dependency on pytest. Actively maintained as of the latest release; however, the package is classified as Development Status 7 - Inactive, indicating minimal ongoing feature work.
Does not work on Windows; requires a POSIX system with fork() support (Linux, macOS). Requires Python 3.10 or later.
License in practice
MIT license permits commercial and private use with minimal restrictions; suitable for most projects.
Quickstart
pip install pytest-forked
pytest --forked
# Or mark individual tests:
@pytest.mark.forked
def test_with_leaky_state():
pass
Verify before relying
- Whether the plugin works correctly with pytest-xdist in all configurations beyond the documented -n3 --forked example.
- Performance overhead of forking per test compared to in-process execution.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagepytest |
| Maintenance | Actively maintained 6 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 7,263,193 / month, #1,761 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 7 - InactiveFramework :: PytestIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: MacOS :: MacOS XOperating System :: POSIXProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Software Development :: Quality AssuranceTopic :: Software Development :: TestingTopic :: Utilities |
Evidence: pytest_forked-1.7.5-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “pytest subprocess isolation”
- pytest-forkedA pytest plugin that runs each test in a forked subprocess to isolate…
- pytest-subprocessPytest plugin that intercepts and fakes subprocess calls, allowing…
- pytest-console-scriptsA pytest plugin that runs Python console scripts within tests,…
Give your agent the search over MCP, or paste the wish link into any chat.
More Utilities packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Detects and normalizes text encoding from unknown or ambiguous sources, supporting all IANA character sets that Python's core library provides codecs for, with the ability to register custom codecs.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
Pygments is a syntax highlighter that colorizes source code and text in over 500 languages and formats, outputting to HTML, LaTeX, RTF, SVG, images, or ANSI terminal sequences.
Install it if you need to display or transform source code.
Six provides utility functions to write Python code that runs on both Python 2.7 and Python 3.3+, smoothing over language differences between the two versions.
See also pytest-subprocess · pytest-xprocess · pytest-rerunfailures · pytest-xdist · pytest-flakefinder · pytest-replay · coverage_enable_subprocess · pytest-parallel · pydantic-monty · isolate