python
install_error
ai_generated
true
FileNotFoundError: [Errno 2] No such file or directory: 'report.html'
ID: python/pytest-html-report-not-generated
80%Fix Rate
86%Confidence
0Evidence
2024-08-11First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 4.x | active | — | — | — |
Root Cause
pytest-html plugin did not generate the report file, often because the plugin is not installed, the output path is incorrect, or the test run crashed before report generation.
generic中文
pytest-html 插件未生成报告文件,通常是因为插件未安装、输出路径不正确,或测试运行在报告生成前崩溃。
Workarounds
-
95% success
pip install pytest-html pytest --html=report.html --self-contained-html
-
88% success
import tempfile import os report_path = os.path.join(tempfile.gettempdir(), 'report.html') # Run pytest with: --html=report_path
Dead Ends
Common approaches that don't work:
-
95% fail
This creates an empty file that does not contain test results. The report will be useless.
-
90% fail
This avoids the error but does not generate the report, defeating the purpose of using pytest-html.