pytest-suite-timeout

raw JSON →
0.1.0 verified Fri May 01 auth: no python

A pytest plugin that enforces a maximum execution time for the entire test suite, preventing runaway test runs. Version 0.1.0. Release cadence unknown (new library).

pip install pytest-suite-timeout
error ModuleNotFoundError: No module named 'pytest_suite_timeout'
cause Package not installed or installed in wrong environment.
fix
Run: pip install pytest-suite-timeout
error TypeError: SuiteTimeoutPlugin() got an unexpected keyword argument 'abort'
cause The 'abort' parameter was added in a later version but user has older version installed.
fix
Update package: pip install --upgrade pytest-suite-timeout, or check version if using an older release.
breaking By default, the plugin does NOT abort the suite if timeout is exceeded; it only prints a warning. Use the 'abort' option to force stop.
fix Set abort=True when initializing SuiteTimeoutPlugin: SuiteTimeoutPlugin(timeout, abort=True)
gotcha The timeout is measured from the start of the first test to the end of the last test, including collection time. If collection takes long, the timeout may trigger prematurely.
fix Increase timeout to account for collection time, or use --collect-only to measure collection duration.
gotcha The plugin relies on the test suite being run in a single process. Parallel execution (e.g., pytest-xdist) is not supported and may cause undefined behavior.
fix Avoid using with xdist, or ensure the plugin runs only in the master process (if supported in future).

Install and register the plugin via conftest.py or pytest.ini.

# conftest.py
import pytest

def pytest_addoption(parser):
    parser.addoption('--suite-timeout', action='store', default=None, type=int,
                     help='Maximum suite execution time in seconds')

def pytest_configure(config):
    timeout = config.getoption('--suite-timeout')
    if timeout:
        from pytest_suite_timeout import SuiteTimeoutPlugin
        config.pluginmanager.register(SuiteTimeoutPlugin(timeout))

# Then run: pytest --suite-timeout=300