Django project: "Run Test" incorrect paths in PyCharm
In my Django project, the project structure is
foo
doc
src
bar
app1
test_models.py
app2
test_models.py
When I right-click on a unit test function (for instance App1Test.test_app) inside the test_models.py file, the "run test" item in the menu says "Run 'Test src.bar.app1.test_models.App1Test.test_app'" and when I execute that I get "ImportError: No module named src".
I have to then edit the configuration (in the toolbar) and manually edit the path (i.e. remove the "src.bar" bit) and run the test for it to work.
Is there anywhere in PyCharm where I can set the path up correctly so it doesn't add the "src.bar" bit?
"bar" is my "Sources Root", so I'm surprised that it adds the directories above "bar" to the path.
Any help much appreciated!
Thanks
Patrick
foo
doc
src
bar
app1
test_models.py
app2
test_models.py
When I right-click on a unit test function (for instance App1Test.test_app) inside the test_models.py file, the "run test" item in the menu says "Run 'Test src.bar.app1.test_models.App1Test.test_app'" and when I execute that I get "ImportError: No module named src".
I have to then edit the configuration (in the toolbar) and manually edit the path (i.e. remove the "src.bar" bit) and run the test for it to work.
Is there anywhere in PyCharm where I can set the path up correctly so it doesn't add the "src.bar" bit?
"bar" is my "Sources Root", so I'm surprised that it adds the directories above "bar" to the path.
Any help much appreciated!
Thanks
Patrick
Please sign in to leave a comment.
I was hoping it would go away in PyCharm 4.0, but no such luck. :(
The only "fix" I found was to exclude the higher directories from the PyCharm project, but since I want to be able to edit files in those directories in PyCharm that's not a solution...
Would be great if someone at JetBrains could give some insight! Thanks!
https://youtrack.jetbrains.com/issue/PY-14677
Let's see if it gets fixed!