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

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 otherwise-passing tests that run for longer than the given duration to be marked as failures. 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

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.1.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_fail_slow-0.1.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest-fail-slow-0.1.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for pytest-fail-slow-0.1.0.tar.gz
Algorithm Hash digest
SHA256 54344c938ab2a4c659bef4ce1757bad581400cf610e8b2ea5e1b1eb59fc9f9bb
MD5 050b16c4f94dd6b693feb5ae507bf2de
BLAKE2b-256 1ec9072608bc065d546403dd98fd3410356b47b322d56c43ce131b4e1f57e2c7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytest_fail_slow-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for pytest_fail_slow-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 90158a2f8757b4dce7da714a2ceb73f6204e948e6b6c49b60d4d462e29c2d77f
MD5 1f3fed4ed4d953398045ee23b1674fab
BLAKE2b-256 e18a8d2a153dbaf6ee49fc19cb82380b430f7d419d692b94fcc845a250918677

See more details on using hashes here.

Supported by

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