Reputation: 27991
I recently discovered the feature "Go To --> Test" in PyCharm.
If I choose "Create New Test", then the target directory of the new python file is wrong.
PyCharm wants to create the new python file in the same directory.
Up to now I use this structure:
src/myapp/setup.py
src/myapp/myapp/real_code.py
src/myapp/myapp/tests/test_real_code.py
How can I tell PyCharm to create test_real_code.py
in above location?
I created a feature request: https://youtrack.jetbrains.com/issue/JT-53069
Just for the records, here are docs about common test layouts: https://docs.pytest.org/en/latest/goodpractices.html#choosing-a-test-layout-import-rules
Upvotes: 14
Views: 1541
Reputation: 3645
In PyCharm Pro 2019.1.2, after clicking on Go To -> Test -> Create New Test...
one can modify the target directory (first box of the pop up box that appears) as long as this directory already exists. The name of the file and of the method can also be changed there.
If a test for the function already exists, even outside the directory, it finds it and proposes to go there when one clicks on Go To -> Test
Upvotes: 4