Skip to main content

pytest-insubprocess

A pytest plugin for running tests in isolated subprocesses.

Features

  • Run pytest tests in separate subprocesses for better isolation
  • Proper handling of test failures and exceptions across process boundaries
  • Maintains pytest's output formatting and reporting
  • Preserves pytest command-line options in subprocesses

Installation

You can install pytest-insubprocess via pip:

pip install pytest-insubprocess

Usage

Once installed, the plugin is automatically registered with pytest. To run your tests in subprocesses, use the --insubprocess flag:

pytest --insubprocess

Basic Example

# test_example.py
import os
import pytest

@pytest.mark.insubprocess
def test_isolated():
    print(f"Running in process: {os.getpid()}")
    assert True

Run with:

pytest test_example.py

Each test will run in its own subprocess, providing complete isolation.

Why Use This Plugin?

  • Process Isolation: Each test runs in a fresh subprocess, preventing side effects between tests
  • Resource Cleanup: Processes are terminated after each test, ensuring clean state
  • Memory Isolation: Memory leaks in one test won't affect others
  • System Resource Independence: Tests that modify system state won't interfere with each other

Requirements

  • Python 3.7 or later
  • pytest 7.0 or later

Development

To contribute to pytest-insubprocess:

  1. Clone the repository:
git clone https://github.com/pchanial/pytest-insubprocess.git
  1. Create a virtual environment and install development dependencies:
python -m venv venv
source venv/bin/activate  # or `venv\Scripts\activate` on Windows
pip install -e ".[test]"
  1. Run the tests:
pytest tests/

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Links

Support

If you are having issues, please let us know by opening an issue on our issue tracker.

Metadata

Release files for pytest-insubprocess 1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-insubprocess 1.2
File Size Uploaded
pytest_insubprocess-1.2.tar.gz 4.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-insubprocess 1.2
File Interpreter ABI Platform
pytest_insubprocess-1.2-py3-none-any.whl Python 3 none any Details

Total release size: 10.7 kB

Release files / pytest_insubprocess-1.2.tar.gz

Download URL pytest_insubprocess-1.2.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
07ce10eb45053394b4acfd3210859b583402c148e4dad6e398c3ad1cdca03a57
BLAKE2b-256 checksum
How to use checksums
3ba230a67cfd24ad489b7af22ed4046e83152f67278ca667c56c0495b50e7f78
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 8, 2025.

Transparency log

Release files / pytest_insubprocess-1.2-py3-none-any.whl

Download URL pytest_insubprocess-1.2-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
31b461946753df8ab5ae02fa318e36f7c6f045c4bfb7cabe41e40bc5571427e9
BLAKE2b-256 checksum
How to use checksums
8ae19c9d3afd9999c92b03c22a81eb10526df55cc407d162b073ab65479e6b3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 8, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

1.2 This release

2 release files

1.1

2 release files

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page