pytest-failure-tracker
A pytest plugin for tracking test failures over multiple test runs, making it easier to identify flaky tests and frequently failing tests.
Installation
You can install pytest-failure-tracker via pip:
pip install pytest-failure-tracker
Usage
To use the plugin, simply run pytest with the --track-failures option:
pytest --track-failures
This will enable failure tracking for your test suite.
Features
Failure Tracking
The plugin tracks the following information for each test:
- Number of passes
- Number of failures
- Number of skips
- Timestamp of the last failure
- Traceback of the last failure
This data is stored in a JSON file (test_results.json) in your project directory.
Summary Report
After each test run with --track-failures enabled, the plugin will display a summary report in the terminal. This report includes:
- Total number of runs for each test
- Number of passes, failures, and skips
- Failure rate
- Timestamp of the last failure
- Traceback of the last failure
Persistent Storage
Test results are stored persistently, allowing you to track failures across multiple test runs and even across different sessions.
Example Output
============================= Test Failure Tracking Summary =============================
test_module.py::test_example:
Total runs: 10
Passes: 8
Failures: 2
Skips: 0
Failure rate: 20.00%
Last failure: 2024-07-16T14:30:00.123456
Last failure traceback:
File "test_module.py", line 15, in test_example
assert False, "This test intentionally fails sometimes"
AssertionError: This test intentionally fails sometimes
test_module.py::test_another_example:
Total runs: 10
Passes: 10
Failures: 0
Skips: 0
Failure rate: 0.00%
Configuration
Currently, the plugin doesn't require any additional configuration beyond the --track-failures command-line option.
Limitations and Considerations
- The plugin treats parameterized tests as separate tests.
- There is currently no built-in way to reset or clear the tracking data. You can manually delete the
test_results.jsonfile to reset. - The plugin doesn't currently provide trend analysis over time.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
TODO: expand documentation with:
- More detailed examples of how to interpret the results
- Any known issues or edge cases
- A section on how to configure the plugin if you add any configuration options in the future
- A more detailed contribution guide if you want to encourage open-source contributions
- A changelog to track versions and updates
Metadata
Release files for pytest-failure-tracker 0.2.3
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_failure_tracker-0.2.3.tar.gz | 10.7 kB | Without provenance | Details for pytest_failure_tracker-0.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pytest_failure_tracker-0.2.3-py3-none-any.whl | Python 3 | none | any | Details for pytest_failure_tracker-0.2.3-py3-none-any.whl |
Total release size: 15.7 kB
Release files / pytest_failure_tracker-0.2.3.tar.gz
| Download URL | pytest_failure_tracker-0.2.3.tar.gz |
|---|---|
| Size | 10.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d8b22f29094d1e7d3fc8cb2a21c31146fba065acc1358e888d452ac5c3c9bd0d
|
|
BLAKE2b-256 checksum How to use checksums |
d1c3fb29102156736bf03dea4d6e2264fc42a762a0c6f1f28e97c513da25f0c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.19
|
Release files / pytest_failure_tracker-0.2.3-py3-none-any.whl
| Download URL | pytest_failure_tracker-0.2.3-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fbecb7462e2b20e2e26055bd05996407f22247be3e7e85483b7ae6e86860f57f
|
|
BLAKE2b-256 checksum How to use checksums |
872486565c43455678246692af56c5e5d0699691e1004fab40dbd1b0755c279c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.19
|
Security for pytest-failure-tracker 0.2.3
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.