python
config_error
ai_generated
true
logging.Handler: 'caplog' fixture requires 'logging' plugin, but logging is not configured
ID: python/pytest-capture-logging-handler
80%Fix Rate
82%Confidence
0Evidence
2024-05-20First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 7.x | active | — | — | — |
| 8.x | active | — | — | — |
Root Cause
pytest的caplog fixture需要pytest的logging插件,如果插件被禁用或未安装,就会报错。
generic中文
pytest的caplog fixture需要pytest的logging插件,如果插件被禁用或未安装,就会报错。
Workarounds
-
90% success
pip install pytest-logging # 在pytest.ini中添加 [pytest] log_cli = true
-
80% success
[pytest] addopts = -p no:logging
Dead Ends
Common approaches that don't work:
-
50% fail
问题不是pytest未安装,而是插件未启用
-
70% fail
caplog是pytest内置的,手动配置不会影响pytest的捕获