I am working on my first python project, and I would like to structure the folders correctly. What I have so far is :
HomeDir/MyProject/
ConfigHandler.py
HomeDir/Tests/
ConfigHanderTests.py
In the ConfigHanderTests.py I am importing a module defined in ConfigHandler.py called ConfigHandler :
from ConfigHandler import ConfigHandler
But when I run the tests using :
python -m unittest ConfigHandlerTests
I get the following error :
ModuleNotFoundError: No module named 'ConfigHandler'
I have read that I need an init.py in the test folder? But other posts mention that is no longer required. If I just have all the python files and test files in one directory, it works fine. But splitting out into folders doesn't work. What am I missing?
Thanks!
Tests/ConfigHanderTests.pyinsideMyProject/and change your imports accordingly.from config_handler.simple import Simpleandfrom config_handler.advanced import Advanced