Marcin
Marcin

Reputation: 611

PyCharm - project structure for test & auto-imports

I have the following project structure:

dev
|_app
  |_package
    |_module.py
    |___init__.py
|_tests
  |_test_util.py
  |_module_test·py
  |___init__.py

I've got trouble configuring PyCharm project structure so that in the same time:

If I set my Content Root to dev then auto-imports work ok, but when I try to run tests which have an import like this:

from tests.test_util import SomeUtil

I'm getting: ImportError: No module named test_util.

If I set my Content Roots to dev/tests and dev/app then whenever I use auto-import (e.g. Alt+Enter) I end up having:

from package import module

even though I expected:

from app.package import module

How do I make PyCharm understand my project structure properly? Defining any folders as sources doesn't help.

Upvotes: 3

Views: 756

Answers (1)

Marcin
Marcin

Reputation: 611

I contacted PyCharm support (very responsive and eager to help I must say). Unchecking "Add Content routes to PYTHONPATH" and "Add Source roots to PYTHONPATH" in my test configurations solved my problem.

Upvotes: 2

Related Questions