A pytest plugin to execute test cases in a subprocess
Project description
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:
- 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/
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.
- 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
Links
- PyPI: pytest-insubprocess
- Source Code: GitHub
- Issue Tracker: GitHub Issues
Support
If you are having issues, please let us know by opening an issue on our issue tracker.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytest_insubprocess-1.1.tar.gz.
File metadata
- Download URL: pytest_insubprocess-1.1.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
395e212e3bdea3ebef802bfd7e93a8fa4db3fdf6758f50c02c7c5b78cac20830
|
|
| MD5 |
e5caacc492f163a35548ce5a5d1a901a
|
|
| BLAKE2b-256 |
3049dcda5ce38583b79f1effc4383855b616f1a2f443004cf5d362c5665d59bf
|
Provenance
The following attestation bundles were made for pytest_insubprocess-1.1.tar.gz:
Publisher:
release.yml on pchanial/pytest-insubprocess
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_insubprocess-1.1.tar.gz -
Subject digest:
395e212e3bdea3ebef802bfd7e93a8fa4db3fdf6758f50c02c7c5b78cac20830 - Sigstore transparency entry: 258558336
- Sigstore integration time:
-
Permalink:
pchanial/pytest-insubprocess@93f3eb7ca9e534b6d7503de8a8bf00ba6925af71 -
Branch / Tag:
refs/tags/v1.1 - Owner: https://github.com/pchanial
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@93f3eb7ca9e534b6d7503de8a8bf00ba6925af71 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pytest_insubprocess-1.1-py3-none-any.whl.
File metadata
- Download URL: pytest_insubprocess-1.1-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a1686f6de583d57c3ebf200573df7082bd3c8d64be8c6ba2835a8bd2315df10
|
|
| MD5 |
a500e8d003f4ee05f5ef77b1a7943af0
|
|
| BLAKE2b-256 |
a49d7de9b3ab063652e1c32b1dd8b9077c2523b2e4647f7be06ffaa3896fa8fe
|
Provenance
The following attestation bundles were made for pytest_insubprocess-1.1-py3-none-any.whl:
Publisher:
release.yml on pchanial/pytest-insubprocess
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_insubprocess-1.1-py3-none-any.whl -
Subject digest:
0a1686f6de583d57c3ebf200573df7082bd3c8d64be8c6ba2835a8bd2315df10 - Sigstore transparency entry: 258558355
- Sigstore integration time:
-
Permalink:
pchanial/pytest-insubprocess@93f3eb7ca9e534b6d7503de8a8bf00ba6925af71 -
Branch / Tag:
refs/tags/v1.1 - Owner: https://github.com/pchanial
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@93f3eb7ca9e534b6d7503de8a8bf00ba6925af71 -
Trigger Event:
release
-
Statement type: