I am currently developing a python package with 3.7.1 and am trying to use unittest with a /test directory containing test modules, which will then contain multiple test cases. I am trying to use the following directory structure:
|_ app/
|_ main.py
|_ my_module/
|_ MyPackage.py
|_ test/
|_ test_MyPackage.py
Inside test_MyPackage.py I am trying to import the required class from MyPackage using from my_module.MyPackage import MyClass as if the module was placed inside the app/ directory but this does not work as the import fails. I know that imports in python don't work like this, and tried it after reading the same question at Running unittest with typical test directory structure which appears to be outdated. I have also read that using python -m unittest should work provided that the test cases are in a /test directory and named test_*.py, but this did not work either, and outputs "Ran 0 tests in 0.000s".
So far the only way I'm able to use my unit tests is to move them to the app/ directory each time I want to run them. Would anybody be able to advise me on the how to use unittests in a separate directory like this without moving them to the app/ directory or importing them with a separate test module permanently inside the app/ directory?