Trying to write tests in Python3 with the folder structure
package/
__init.py__
Foo.py
Bar.py
test/
__init.py__
test_Foo.py
Foo.py
import Bar
test_Foo.py
import Foo
Running python3 -m unittest
results in No module named Foo
If I changed it to
from package import Foo
It will resolve, but in Foo.py
it'll have the error No module named 'Bar'
If I change Foo.py
to
from package import Bar
The test will run without error, but running python3 Foo.py
will result in No module named 'package'
I've gone through various answers about this kind of problems, like this one
Running unittest with typical test directory structure
and this
Python3 import modules from folder to another folder
and none of them address this issue