pytest-errxfail
A pytest plugin that adds the xfail_err marker to xfail a test that failed with the specified error message in the captured stdout, stderr or log output.
This plugin can be useful in the following cases:
there are many tests failing due to sporadic problems (e.g., caused by an unstable network or sporadic crashes of a running third-party subprocess) and you want to save time analyzing test reports by splitting known flaky tests failures from meaningful software defects
it is necessary to ensure that the original error in the test marked as xfail does not change in future revisions
Requirements
Python >= 3.8
pytest >= 6.2.0
Installation
pip install pytest-errxfail
Usage
Just add the xfail_err marker to the tests you need with the following arguments:
positional argument with the error message pattern (can be also specified as the pattern kwarg)
reason keyword argument - xfail reason (optional)
matcher keyword argument - the type of message pattern matching (optional):
plain - simple substring search (default)
re - regular expression (with re.MULTILINE flag)
glob - Unix shell-style wildcard (via fnmatch)
Example:
@pytest.mark.xfail_err('Error when downloading https://example.com/data* - connection refused',
matcher='glob', reason='unstable network')
def test_download_file():
run("echo 'Error when downloading https://example.com/data12 - connection refused' && exit 1",
shell=True, check=True)
Output:
$ pytest -v =============================== test session starts ================================ platform linux -- Python 3.12.3, pytest-8.3.4, pluggy-1.5.0 -- /tmp/venv/bin/python3 cachedir: .pytest_cache rootdir: /media/eltio/d893d5b1-92cd-4a48-a51e-7e94a871dbf1/repo/current/test_py plugins: errxfail-0.1.0 collected 1 item test_demo.py::test_download_file XFAIL (unstable network) [100%] ================================ 1 xfailed in 0.03s ================================
Issues
If you encounter any problems, feel free to file an issue along with a detailed description and a minimal reproducible example.
License
Distributed under the terms of the MIT license, “pytest-errxfail” is free and open source software
Metadata
Release files for pytest-errxfail 0.1.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_errxfail-0.1.0.tar.gz | 6.1 kB | Without provenance | Details for pytest_errxfail-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pytest_errxfail-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for pytest_errxfail-0.1.0-py3-none-any.whl |
Total release size: 12.5 kB
Release files / pytest_errxfail-0.1.0.tar.gz
| Download URL | pytest_errxfail-0.1.0.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
29e80c7ace1f005c2c5235b57b282dac6bd36352f2fb10c8a9e0170214723779
|
|
BLAKE2b-256 checksum How to use checksums |
49819a8c8a3b4c8f02bf2ca11b4b8690db21002ee0f6767f3b661d71782e94a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.3
|
Release files / pytest_errxfail-0.1.0-py3-none-any.whl
| Download URL | pytest_errxfail-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
74882e5ec99b7161ac20f937e95efc72ecd500326f2e51e1ef321538bff3b806
|
|
BLAKE2b-256 checksum How to use checksums |
41b741b4dd23375f6c155635e6145ae304122e70eca309075d134e6333347474
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.3
|
Security for pytest-errxfail 0.1.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.