I created a function and tried importing it into another python script to do some unit tests. However I am constantly getting a ModuleNotFoundError
. How do I properly import functions form one script to another?
My code:
from src.somefile import some_function
def test_somefunction:
assert somefunction()
The error I encounter:
Traceback (most recent call last):
File "test/test_file.py", line 2, in <module>
from src.somefile import convert_epoch
ModuleNotFoundError: No module named 'src'
My folder structure:
project/
project/__init__.py
project/src
project/src/__init__.py
project/src/somefile.py
project/test
project/test/__init__.py
project/test/test_file.py
I would appreciate if someone could highlight what I am doing wrong and how I can neatly do an import. Thank you!