I would like to import modules from another folder and test them. My directory looks like this:
- relative_imports:
- folder1:
- file1.py
- class one_1(): ...
- class one_2(): ...
- file2.py
- class two_1(): ...
- class two_2(): ...
- folder2:
- file3.py
In file3.py I would like to import classes: one_1, one_2, two_1, two_2. From file1.py and file2.py. I want to be able to access and test these classes.
I would not like to use the sys path method, but I would rather work with relative paths from the point of view of file3.py.
I have tried several variations of the following code with no success.
from relative_imports.folder1.file1 import one_1
val = one_1()
I have also tried using __init__.py files but I seem to have not found the correct method of importing the modules.