pytest-quarantine
A plugin for pytest to manage expected test failures.
Features
Save the list of failing tests, so that they can be automatically marked as expected failures on future test runs.
Why?
You've got a test suite; nicely done! Unfortunately, for completely understandable reasons, a lot of the tests are failing. Someday, you and/or your team will get those tests to pass. For now, though, what you really want is to draw a line in the sand and avoid new test failures. Unfortunately, it's hard to tell when they're introduced because the test suite is already failing. You could get the test suite to pass by applying pytest.mark.xfail to the existing failures, but there are so many of them.
With this plugin, you can save all of existing failures to a file (the quarantine). On future test runs, this plugin will automatically apply pytest.mark.xfail to the quarantined tests. Then, the test suite will pass, and any new failures will cause it to fail.
Requirements
- Python 2.7 or 3.5+
- pytest 4.6 or newer
Installation
Via pip from PyPI in an active virtual environment:
$ pip install pytest-quarantine
Usage
Run your test suite and save the failing tests to quarantine.txt:
$ pytest --save-quarantine=quarantine.txt
============================= test session starts ==============================
...
collected 1380 items
...
---------------------- 661 items saved to quarantine.txt -----------------------
============== 629 failed, 719 passed, 32 error in 312.56 seconds ==============
Add quarantine.txt to your version control system.
Run your test suite with the quarantined tests marked as expected failures:
$ pytest --quarantine=quarantine.txt
============================= test session starts ==============================
...
collected 1380 items
added mark.xfail to 661 of 661 items from quarantine.txt
...
================== 719 passed, 661 xfailed in 300.51 seconds ===================
When the expected failures eventually pass (i.e., they get counted as xpassed), they can be removed manually from quarantine.txt, or automatically using --save-quarantine. Note that the latter will overwrite the contents of the quarantine, so it's best to only use it when running the entire test suite.
Getting help
Please submit questions, bug reports, and feature requests in the issue tracker.
Contributing
Improvements to the code and documentation are greatly appreciated. See How to contribute for details.
Code of conduct
Everyone interacting with this project is expected to follow the Contributor Covenant.
License
Distributed under the terms of the MIT license.
Acknowledgements
This project was initially developed at EnergySage to aid our migration to Python 3. We hope other people find it helpful.
The name was inspired by the quarantine feature of the Bamboo CI/CD service. Pros and Cons of Quarantined Tests is a good introduction to the concept (not related to this project).
The repository was generated with Cookiecutter using the cookiecutter-pytest-plugin template. The layout and tooling has been heavily modified since then, but it was very helpful to start.
Some other helpful resources were:
- Starting an Open Source Project | Open Source Guides
- Testing & Packaging | Hynek Schlawack
- Maintaining a Python Project When It’s Not Your Job | Hynek Schlawack
- Python Testing with pytest | Brian Okken | The Pragmatic Bookshelf
- Developing better test suites for pytest plugins | Raphael Pierzina
- GitHub search for examples from
org:pytest-dev org:pypa org:pycqa org:pallets org:encode
Metadata
Release files for pytest-quarantine 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pytest_quarantine-2.0.0.tar.gz | 14.9 kB | Without provenance | Details for pytest_quarantine-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pytest_quarantine-2.0.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for pytest_quarantine-2.0.0-py2.py3-none-any.whl |
Total release size: 21.6 kB
Release files / pytest_quarantine-2.0.0.tar.gz
| Download URL | pytest_quarantine-2.0.0.tar.gz |
|---|---|
| Size | 14.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dda53da57c8150e99982f092ceed6d65c85031e0215a5689a3f150801851aaac
|
|
BLAKE2b-256 checksum How to use checksums |
955a47db22b0f863bb4f33187e2f97c710dab27d5d542fedcc228b80980a7502
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.4
|
Release files / pytest_quarantine-2.0.0-py2.py3-none-any.whl
| Download URL | pytest_quarantine-2.0.0-py2.py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
8bfa7db4f43e85c06449713b9655b23c6e5470b84f1f0200f84b3d945615438b
|
|
BLAKE2b-256 checksum How to use checksums |
b698f1dc0080ac5f0a69ed016b5b7c953671aaa72667a2de70bfaf3a3e67f674
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.4
|
Security for pytest-quarantine 2.0.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.