python install_error ai_generated true

ERROR: usage: pytest [options] [file_or_dir] [file_or_dir] [...] pytest: error: unrecognized arguments: --timeout=60 inifile: /app/pytest.ini rootdir: /app

ID: python/pytest-timeout-plugin-missing

Also available as: JSON · Markdown · 中文
80%Fix Rate
91%Confidence
0Evidence
2024-03-28First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
6.x active — — —
7.x active — — —
8.x active — — —

Root Cause

The pytest.ini contains `addopts = --timeout=60` but the pytest-timeout plugin is not installed, so pytest rejects the unknown option.

generic

中文

pytest.ini 中包含 `addopts = --timeout=60`,但未安装 pytest-timeout 插件,因此 pytest 拒绝该未知选项。

Workarounds

  1. 98% success
    pip install pytest-timeout
    # then pytest.ini's addopts = --timeout=60 works
  2. 75% success
    import signal
    import pytest
    
    @pytest.fixture
    def timeout():
        def handler(signum, frame):
            raise TimeoutError('test timed out')
        signal.signal(signal.SIGALRM, handler)
        signal.alarm(60)
        yield
        signal.alarm(0)

Dead Ends

Common approaches that don't work:

  1. 80% fail

    Removes the timeout protection entirely; long-hanging tests can block CI indefinitely.

  2. 98% fail

    Same unrecognized-argument error occurs because the plugin is still missing.