No project description provided
Project description
pytest-isolate
Isolate each test in a subprocess - pytest forked replacement, based on pytest-forked.
This pytest plugin was generated with Cookiecutter along with @hackebrot
's cookiecutter-pytest-plugin
template.
Features
- Run each test in an forked, isolated subprocess
- Captures stdout & stderr of crashing processes
- Add Timeout to a forked test
- Limit memory used by test
- Plays nice with pytest-xdist
- Shows warnings, even with xdist!
Requirements
- pytest
Installation
You can install "pytest-isolate" via pip
from PyPI
pip install pytest-isolate
Usage
pytest --isolate
To run every test in its own forked subprocess.
Or:
pytest --isolate-timeout 10 --isolate-mem-limit 1000000
To set a timeout to every test in addition to forking.
Note:
Since this plugin uses
fork
, it will not work on operating systems withoutfork
support (e.g. Windows).
The flags --timeout
or --forked
will also be respected such that pytest-isolate
is a drop-in replacement forked pytest forked and pytest timeout.
If pytest-forked
or pytest-timeout
are installed, then
they will take precedence. Uninstall them to use pytest-isolate
.
Unlike pytest-timeout
, timeout in pytest-isolate
is implemented by forking the test to a separate subprocess, and setting timeout for that subprocess.
You can also use a mark to isolate or time limit the memory test:
@pytest.mark.isolate(timeout=10,mem_limit=10**6)
def test_something():
pass
The options can also be set in an pytest configuration file, e.g:
[tool.pytest.ini_options]
isolate_timeout=10
isolate_mem_limit=1000000
Contributing
Contributions are very welcome. Tests can be run with tox
, please ensure
the coverage at least stays the same before you submit a pull request.
License
Distributed under the terms of the MIT
, pytest-isolate
is free and open source software
Issues
If you encounter any problems, please file an issue along with a detailed description.
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
File details
Details for the file pytest_isolate-0.0.2.tar.gz
.
File metadata
- Download URL: pytest_isolate-0.0.2.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b885fabf989d9f0f2f010b64840c8f6ac3338c8952960d6c7f8e7de2ff5a6ee2 |
|
MD5 | a8a661eb7e2ceaee05b154c509615e34 |
|
BLAKE2b-256 | 14636fbcacb155de37771984a13a5ec83689d09dd9ba5d646049be86dd248e4d |
File details
Details for the file pytest_isolate-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: pytest_isolate-0.0.2-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64e262b4f7da05c81f09f126ee321a95bdac207d2bd8a1ab0b58c305038fc068 |
|
MD5 | 7393c9c5be70d16ed02a561eaf90941f |
|
BLAKE2b-256 | 7d0e137a854e7e664f3d081964727abc4dda5002cd0fa814f692382a663bf33e |