简体   繁体   English

当py.test测试失败时,PyCharm可以进入调试状态

[英]Can PyCharm drop into debug when py.test tests fail

When running tests with py.test there is a --pdb option to enter pdb on failure. 使用py.test运行测试时,有一个--pdb选项可在失败时输入pdb。

Is there a similar way to enter the debugger when running the same test from within PyCharm? 在PyCharm中运行相同的测试时是否有类似的方法进入调试器?

有一个py.test插件pytest-pycharm ,它会在测试发出未捕获的异常时暂停PyCharm调试器。

Follow the steps below to setup the correct run configuration: 请按照以下步骤设置正确的运行配置:

  1. Run > Edit Configurations... 运行>编辑配置...
  2. Click the '+' button to add a new configuration. 单击“+”按钮添加新配置。
  3. Name the configuration and specify the configuration parameters below: 命名配置并指定以下配置参数:

Script : The path to your py.test executable (find by typing which py.test ) 脚本 :py.test可执行文件的路径(通过键入which py.test

Script Parameters : This parameter is your test case followed by the --pdb option (ie /Users/Johan/projects/misc/testing.py --pdb ) 脚本参数 :此参数是您的测试用例,后跟--pdb选项(即/Users/Johan/projects/misc/testing.py --pdb

After setting up the configuration, you can run the test case from within PyCharm. 设置配置后,您可以在PyCharm中运行测试用例。 If a test case fails, your PyCharm run window will show the pdb prompt. 如果测试用例失败,PyCharm运行窗口将显示pdb提示符。

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM