I have the following file structure:
C:.
├───jobs_struct
│ │
│ └───app
│ └───job_struct
│ │ delta.py
│
└───test
├───integration
└───unitaire
│ test_delta.py
test_delta.py
is a pytest file and import delta.py
to test its functions.
In test_delta.py
, I do not understand how I am supposed to import delta.py
. I have tried the following:
Attempt 1
sys.path.append("../../")
from jobs_struct.app.job_struct.delta import ApplyDelta
Throws:
E ModuleNotFoundError: No module named 'jobs_struct'
Attempt 2
from jobs_struct.app.job_struct.delta import ApplyDelta
E ModuleNotFoundError: No module named 'jobs_struct'
Attempt 3
sys.path.append("/jobs_struct/app/job_struct")
from delta import ApplyDelta
from delta import ApplyDelta
E ModuleNotFoundError: No module named 'delta'
Additionnal details
Some answers recommend to include init.py files at specific locations (or everywhere). I would like to avoid changing/adding anything to the app itself.
Moreover, the pytest command is ran from the root of the project (if that has any impact).
Question
How to correctly import my module, knowing that using absolute path is not an option, in order to be able to run my test file.