Django project: "Run Test" incorrect paths in PyCharm

In my Django project, the project structure is


When I right-click on a unit test function (for instance App1Test.test_app) inside the file, the "run test" item in the menu says "Run 'Test'" 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 "" 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 "" bit?

"bar" is my "Sources Root", so I'm surprised that it adds the directories above "bar" to the path.

Any help much appreciated!

This is also an issue when re-running failed tests, as it will try running them with the incorrect path
This has been bugging me for months, but I haven't taken the time to boil down a minimal test-case for it.
I was hoping it would go away in PyCharm 4.0, but no such luck. :(
I've gone through pretty much every setting, no 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!
Unfortunately I don't see JetBrains participate in this forum very much. I've had better luck with the bug tracker – and this is definitely a bug.
I've added a issue to the bug tracker:

Let's see if it gets fixed!

Please sign in to leave a comment.