I usually assume that a similar answer is available on the internet, so please direct me if so. I have been searching for several hours, so decided to ask the community.
I am new to testing and attempting to set up a structure as follows (in a Windows env):
-parentFolder
-__init__.py
-src
-__init__.py
-fileA.py
-fileB.py
-test
-__init__.py
-test_fileA.py
FileA contents:
import fileB
# do something
test_fileA contents (just trying to get imports working first):
import sys
sys.path.append('..')
from src import fileA
if __name__ == "__main__":
print('success')
The code I am running/error I am receiving back is
C:\parentFolder >> python -m tests.test_fileA
...
File "C:\parentFolder\src\fileA.py", line 14, in <module>
import fileB
ModuleNotFoundError: No module named 'fileB'
I am guessing that this has to do with relative paths? I was able to work around using
from . import fileB
but this feels hacky. What would the proper solution be?