You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何让PyCharm终端中pytest输出的文件路径可点击?

问题:PyCharm终端中pytest输出的文件路径如何设置为可点击状态

在PyCharm终端执行pytest --cov命令时,得到如下输出:

FAIL Required test coverage of 100.0% not reached. Total coverage: 55.03%
=========================================================================================================================================== short test summary info =========================================================================================================================================== 
FAILED test/fhg_isi/plotting/test_matplotlib.py::test_create_graph - TypeError: create_graph() missing 1 required positional argument: 'template'
FAILED test/fhg_isi/plotting/test_matplotlib.py::test_create_graph_having_subplots - TypeError: create_graph_having_subplots() missing 1 required positional argument: 'template'

希望让输出中的文件路径变为可点击状态,能快速在PyCharm中打开对应文件,询问是否需要特定覆盖率报告类型或调整PyCharm终端设置。

解决方法
  • 调整PyCharm终端设置即可,无需修改覆盖率报告类型:

    1. 打开PyCharm的Settings(Windows/Linux按Ctrl+Alt+S,Mac按Cmd+,)
    2. 导航到Tools > Terminal
    3. 找到Shell integration选项,确保勾选**"Enable shell integration"**
    4. 关闭当前终端窗口后重新打开
  • 如果上述设置无效,可指定pytest输出格式:
    执行命令时添加--tb=short参数,让输出格式更贴合PyCharm的路径识别规则:

    pytest --cov --tb=short
    

    你的输出中文件路径格式本身已符合要求,开启shell集成后即可触发点击跳转。

内容的提问来源于stack exchange,提问作者Stefan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 08:32:03