python
install_error
ai_generated
true
ERROR: 用法: pytest [options] [file_or_dir] [file_or_dir] [...] pytest: error: 无法识别的参数: --timeout=60 inifile: /app/pytest.ini rootdir: /app
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
80%修复率
91%置信度
0证据数
2024-03-28首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 6.x | active | — | — | — |
| 7.x | active | — | — | — |
| 8.x | active | — | — | — |
根因分析
pytest.ini 中包含 `addopts = --timeout=60`,但未安装 pytest-timeout 插件,因此 pytest 拒绝该未知选项。
English
The pytest.ini contains `addopts = --timeout=60` but the pytest-timeout plugin is not installed, so pytest rejects the unknown option.
解决方案
-
98% 成功率
pip install pytest-timeout # then pytest.ini's addopts = --timeout=60 works
-
75% 成功率
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)
无效尝试
常见但无效的做法:
-
80% 失败
Removes the timeout protection entirely; long-hanging tests can block CI indefinitely.
-
98% 失败
Same unrecognized-argument error occurs because the plugin is still missing.