experimental/sources/: pytest-forked-1.6.0 metadata and description

Homepage Simple index

run tests in isolated forked subprocesses

author pytest-dev
author_email pytest-dev@python.org
classifiers
  • Development Status :: 7 - Inactive
  • Framework :: Pytest
  • Intended Audience :: Developers
  • License :: OSI Approved :: MIT License
  • Operating System :: POSIX
  • Operating System :: MacOS :: MacOS X
  • Topic :: Software Development :: Testing
  • Topic :: Software Development :: Quality Assurance
  • Topic :: Utilities
  • Programming Language :: Python
  • Programming Language :: Python :: 3
  • Programming Language :: Python :: 3.7
  • Programming Language :: Python :: 3.8
  • Programming Language :: Python :: 3.9
  • Programming Language :: Python :: 3.10
  • Programming Language :: Python :: 3.11
  • Programming Language :: Python :: 3 :: Only
description_content_type text/x-rst
license MIT
platform
  • linux
  • osx
requires_python >=3.7
File Tox results History
pytest-forked-1.6.0.tar.gz
Size
10 KB
Type
Source

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

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.