Skip to main content

Fail tests that take too long to run

Project description

Project Status: Active — The project has reached a stable, usable state and is being actively developed. CI Status https://codecov.io/gh/jwodder/pytest-fail-slow/branch/master/graph/badge.svg https://img.shields.io/pypi/pyversions/pytest-fail-slow.svg MIT License

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-fail-slow-0.2.0.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

pytest_fail_slow-0.2.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file pytest-fail-slow-0.2.0.tar.gz.

File metadata

  • Download URL: pytest-fail-slow-0.2.0.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.12

File hashes

Hashes for pytest-fail-slow-0.2.0.tar.gz
Algorithm Hash digest
SHA256 cd493193683ffd6f7969c40fcc52733279a3e55686161f7bd44c6ca464d16dd7
MD5 e0474084996b3c824f1348a00c3f5ebd
BLAKE2b-256 e376faf9477608fad2697f06ea97be2edb7a91e71cb74ce3b1a8de309e8e9472

See more details on using hashes here.

File details

Details for the file pytest_fail_slow-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pytest_fail_slow-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.12

File hashes

Hashes for pytest_fail_slow-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f23a2d39e5e3122c553c93d30824cd5ac0565845deb4ba76101fd080ca088986
MD5 dc5670b721b183cf6866e663493a2592
BLAKE2b-256 74bd72b60ec93447adb8803fd8e78d8aa79610a12bc0e0fae94c0b3240d0099f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page