Run py.test in pycharm 2019.2
In pycharm 2019.2, you can follow the steps below
- 1. Enter Run > Edit Configurations then Add pytest
- 2. Set options showed below
- 3. Click Debug
Run py.test in PyCharm 2017.3
- Enter edit configurations
- Add a new run config and select py.test
- In the run config details, set
target=pythonand the unnamed field below to tests.
Also recommend the
-sparameter which makes console output behave properly. otherwise pytest will capture the output and make the debug console buggy.
Notice: in PyCharm 2020.1.2 Pro, the Target buttons in the screenshot below are named: “Module name”, “Script path”, “Costum”. Choosing “Module name” works
- Tests folder looks like that. just below the root of my project (my_project/tests).
foobar_test.pyfile: (no imports needed):
Code language: PHP (php)
def test_foobar(): print("hello pytest") assert True
Now you can run pytest with the normal run command