A pytest plugin for enhanced test reliability and monitoring
Project description
Features
- Resource Enforcement: Set hard limits on Time, Memory (MB), and CPU (%).
- Stall Detection: Detects deadlocks by monitoring low CPU usage over time.
- Global Session Timeout: Set a maximum duration for the entire test run, with graceful and forceful termination.
- CI Awareness: Automatically scales limits (default
2x) when running in CI environments. - Flake Management: Built-in retry mechanism for failed or resource-violating tests.
- Detailed Reporting: Generates JSON reports with resource usage metrics.
- Debug context: Dumps thread stacks upon timeout/interrupt.
Installation
uv add -D pytest-vigil
# or
pip install pytest-vigil
Usage
CLI Options
| Option | Unit | Required | Default | Description |
|---|---|---|---|---|
--vigil-timeout |
s |
No | None |
Test timeout |
--vigil-memory |
MB |
No | None |
Memory limit |
--vigil-cpu |
% |
No | None |
CPU limit |
--vigil-retry |
- | No | 0 |
Number of retries on failure |
--vigil-stall-timeout |
s |
No | None |
Max duration of low CPU activity |
--vigil-stall-cpu-threshold |
% |
No | 1.0 |
CPU threshold for stall detection |
--vigil-session-timeout |
s |
No | None |
Global timeout for entire test run |
--vigil-session-timeout-grace-period |
s |
No | 5.0 |
Grace period before forceful termination |
--vigil-report |
- | No | None |
Path to JSON report file |
--vigil-cli-report-verbosity |
- | No | short |
Terminal report display: none, short (summary), full |
pytest --vigil-timeout 5 --vigil-memory 512 --vigil-cpu 80
Terminal Report Verbosity
Control how much of the reliability report is displayed in the terminal. Available options:
none: No reliability report displayed (useful for CI pipelines where you only need JSON reports)short: Display summary statistics only (total tests, averages, fastest/slowest tests)full: Display detailed table with all tests (default behavior)
# Hide terminal report completely
pytest --vigil-cli-report-verbosity none
# Show summary statistics only (default)
pytest --vigil-cli-report-verbosity short
# Show all tests in detailed table
pytest --vigil-cli-report-verbosity full
Configuration:
- CLI:
--vigil-cli-report-verbosity short - Environment:
PYTEST_VIGIL__REPORT_VERBOSITY=short
Global Session Timeout
Set a maximum duration for the entire test run. If the total execution time exceeds this limit, pytest-vigil will automatically terminate the test run.
# Terminate if test run exceeds 15 minutes
pytest --vigil-session-timeout 900
Termination Behavior:
- Graceful Termination: Upon timeout, pytest-vigil sends
SIGTERM(orSIGINTon systems withoutSIGTERM) to allow ongoing tests to complete and clean up resources. - Grace Period: Waits some time (configurable via
PYTEST_VIGIL__SESSION_TIMEOUT_GRACE_PERIOD) for graceful shutdown. - Forceful Termination: If the process doesn't terminate within the grace period, pytest-vigil sends
SIGKILLto forcefully stop the test run.
CI Environment: Like per-test limits, session timeout is automatically multiplied by the CI multiplier (default 2x) when running in CI environments.
Configuration:
- CLI:
--vigil-session-timeout 900 --vigil-session-timeout-grace-period 10 - Environment:
PYTEST_VIGIL__SESSION_TIMEOUT=900.0 - Grace period environment:
PYTEST_VIGIL__SESSION_TIMEOUT_GRACE_PERIOD=5.0
Markers
Apply limits to specific tests. All arguments are optional.
| Parameter | Type | Unit | Default | Description |
|---|---|---|---|---|
timeout |
float |
s |
None |
Test timeout |
memory |
float |
MB |
None |
Memory limit |
cpu |
float |
% |
None |
CPU limit |
retry |
int |
- | 0 |
Number of retries on failure |
stall_timeout |
float |
s |
None |
Max duration of low CPU activity |
stall_cpu_threshold |
float |
% |
1.0 |
CPU threshold for stall detection |
import pytest
@pytest.mark.vigil(timeout=5.0, memory=512, retry=2)
def test_critical_path():
...
Configuration (Env)
Configure via environment variables (prefix PYTEST_VIGIL__):
PYTEST_VIGIL__TIMEOUT=5.0PYTEST_VIGIL__CI_MULTIPLIER=2.0PYTEST_VIGIL__STALL_TIMEOUT=10.0PYTEST_VIGIL__SESSION_TIMEOUT=900.0PYTEST_VIGIL__SESSION_TIMEOUT_GRACE_PERIOD=5.0PYTEST_VIGIL__REPORT_VERBOSITY=short# Options: none, short, full
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_vigil-0.5.0.tar.gz.
File metadata
- Download URL: pytest_vigil-0.5.0.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
638ffec4683a7c870eea585e9d8b60261878b278837a68a1f3f483961b0631c0
|
|
| MD5 |
3570e6c4321126f120e0d86740ec4e36
|
|
| BLAKE2b-256 |
588d73c39a2921972f5edf804765f40f39c510078f1bfe5d8738b23167ccbbcf
|
Provenance
The following attestation bundles were made for pytest_vigil-0.5.0.tar.gz:
Publisher:
publish-to-pypi.yml on l0kifs/pytest-vigil
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_vigil-0.5.0.tar.gz -
Subject digest:
638ffec4683a7c870eea585e9d8b60261878b278837a68a1f3f483961b0631c0 - Sigstore transparency entry: 924401832
- Sigstore integration time:
-
Permalink:
l0kifs/pytest-vigil@f3f84754c869284761e0db0f9bb7a093b01d7925 -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/l0kifs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@f3f84754c869284761e0db0f9bb7a093b01d7925 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pytest_vigil-0.5.0-py3-none-any.whl.
File metadata
- Download URL: pytest_vigil-0.5.0-py3-none-any.whl
- Upload date:
- Size: 17.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
73003b9b522a1021973a2e8016020f02fb53b909d6557c38ba6c480a9e66aad2
|
|
| MD5 |
613f99492d3831eef75ef13b34351f6b
|
|
| BLAKE2b-256 |
fefab8f66382cf4b365c92eeb88bb65f59c85d2b2d3121a73cfcef04a13cbfce
|
Provenance
The following attestation bundles were made for pytest_vigil-0.5.0-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on l0kifs/pytest-vigil
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_vigil-0.5.0-py3-none-any.whl -
Subject digest:
73003b9b522a1021973a2e8016020f02fb53b909d6557c38ba6c480a9e66aad2 - Sigstore transparency entry: 924401836
- Sigstore integration time:
-
Permalink:
l0kifs/pytest-vigil@f3f84754c869284761e0db0f9bb7a093b01d7925 -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/l0kifs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@f3f84754c869284761e0db0f9bb7a093b01d7925 -
Trigger Event:
release
-
Statement type: