Can PyCharm drop into debug when py.test tests fail

筅森魡賤 提交于 2019-12-03 07:34:59

问题


When running tests with py.test there is a --pdb option to enter pdb on failure.

Is there a similar way to enter the debugger when running the same test from within PyCharm?


回答1:


There is a py.test plugin, pytest-pycharm, that will halt the PyCharm debugger when a test emits an uncaught exception.




回答2:


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)

Script Parameters: This parameter is your test case followed by the --pdb option (ie /Users/Johan/projects/misc/testing.py --pdb)

After setting up the configuration, you can run the test case from within PyCharm. If a test case fails, your PyCharm run window will show the pdb prompt.



来源:https://stackoverflow.com/questions/24172921/can-pycharm-drop-into-debug-when-py-test-tests-fail

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!