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

启动调试器时site-packages代码断点失效的问题排查

调试pytest单元测试无法步入库函数的问题

环境信息

  • MacOS Monterey
  • Python 3.9.13
  • VS Code 1.76.2
  • pytest==7.2.0
  • 使用virtualenv虚拟环境

问题详情

调试单元测试时,尝试步入库函数却无法进入,程序直接运行完成;手动在库代码中设置断点也没有效果。

我已经在launch.json中设置justMyCode为false,配置内容如下:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "justMyCode": false
        }
    ]
}

参考相关方案后,我尝试将site-packages目录添加到工作区,但没有任何变化。

初始状态下,库代码中的断点可以正常显示(标记为已设置状态),但一旦执行“Debug test”操作,这些库代码里的断点就会被自动禁用。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.28 11:22:47