Fail tests that take too long to run
Project description
GitHub | PyPI | Issues | Changelog
pytest-fail-slow is a pytest plugin for making tests fail that take too long to run. It adds a --fail-slow DURATION command-line option to pytest that causes any & all otherwise-passing tests that run for longer than the given duration to be marked as failures, and it adds a @pytest.mark.fail_slow(DURATION) marker for making an individual test fail if it runs for longer than the given duration. If --fail-slow is given and a test has the @fail_slow() marker, the duration given by the marker takes precedence for that test.
Note that slow tests will still be run to completion; if you want them to instead be stopped early, use pytest-timeout.
A duration can be supplied to the --fail-slow option as either a bare floating-point number of seconds or as a floating-point number followed by one of the following units (case insensitive):
h, hour, hours
m, min, mins, minute, minutes
s, sec, secs, second, seconds
ms, milli, millisec, milliseconds
us, μs, micro, microsec, microseconds
Durations passed to the @pytest.mark.fail_slow() marker can be either ints/floats (for a number of seconds) or strings in the same format as passed to --fail-slow.
If pytest-fail-slow marks a test as a failure, the output will include the test’s duration and the duration threshold, like so:
________________________________ test_func ________________________________ Test passed but took too long to run: Duration 123.0s > 5.0s
Note: Only the durations for tests themselves are taken into consideration. If a test passes in less than the specified duration, but one or more fixture setups/teardowns take longer than the duration, the test will still be marked as passing.
Installation
pytest-fail-slow requires Python 3.6 or higher and pytest 6.0 or higher. Just use pip for Python 3 (You have pip, right?) to install it:
python3 -m pip install pytest-fail-slow
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
Hashes for pytest_fail_slow-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf8b57a90d13f8f694ad8250c6d2e869714422c5d7f3c2d6541bec7d1706f783 |
|
MD5 | babd754ee90e5ffc468261d215ab7caf |
|
BLAKE2b-256 | a2bb275f32982bd4f7a5c52639a1cb9571f0716d1b50647e607beb88769d9ff3 |