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?
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?
There is a py.test plugin, pytest-pycharm, that will halt the PyCharm debugger when a test emits an uncaught exception.
pyenv
, as it uses shell-script shims to wrap python programs such as pytest
, and his means that PyCharm is not directly running a Python program, so cannot engage the debugger. –
Kristy Follow the steps below to setup the correct run configuration:
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.
If breakpoints work, but just drop into debug does not happen, check
File > Settings > Build, Execution, Deployment > Python Debugger > Drop into debugger on failed tests.
© 2022 - 2025 — McMap. All rights reserved.