aName
aName

Reputation: 3043

pytest no module named common

I'm trying to get started with python and pytest, I have the following project structure :

.
├── my_module
│   ├── __init__.py
│   ├── common
│   │   ├── __init__.py
│   │   └── utils.py
│   └── my_script.py
└── test
    ├── __init__.py
    └── test_my_script.py

When I run tests (using pytest), I get an error:

no module named 'common'.

I have also the following all configs files:


someone know what I missed?
EDIT here is how I import utils from test_my_script.py :

from common.util import func1,func2

Upvotes: 0

Views: 1315

Answers (1)

pL3b
pL3b

Reputation: 1329

common.util module is not accessible from your test execution because it is located in my_module package. You should use import starting from working directory which is your project root.

Consider using following import instead:

from my_module.common.util import func1, func2

Upvotes: 1

Related Questions