A pytest plugin for running tests in isolated subprocesses.
- 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
You can install pytest-insubprocess via pip:
pip install pytest-insubprocessOnce installed, the plugin is automatically registered with pytest. To run your tests in subprocesses, use the --insubprocess flag:
pytest --insubprocess# test_example.py
import os
import pytest
@pytest.mark.insubprocess
def test_isolated():
print(f"Running in process: {os.getpid()}")
assert TrueRun with:
pytest test_example.pyEach test will run in its own subprocess, providing complete isolation.
- 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
- Python 3.7 or later
- pytest 7.0 or later
To contribute to pytest-insubprocess:
- Clone the repository:
git clone https://github.com/pchanial/pytest-insubprocess.git- 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]"- Run the tests:
pytest tests/This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- PyPI: pytest-insubprocess
- Source Code: GitHub
- Issue Tracker: GitHub Issues
If you are having issues, please let us know by opening an issue on our issue tracker.