I have a python3 project organized like this:
project
src
__init.py__
file1.py (contains Class1)
file2.py (contains Class2)
test
test1.py (contains TestClass1)
test2.py (contains TestClass2)
I want to be able to import classes from file1.py
into file2.py
and from either file1.py
or file2.py
into test1.py
and test2.py
. What's the most straightforward way to accomplish this without setting sys.path
?
I'm using python 3.7.
The code gets called as:
cd project/src/ && python3 file2.py
and as:
cd project/ && python3 -m unittest discover
This is an open-source project, so anyone who wants is welcome to the URL for our GitHub repo, but I expect it's not relevant to the question.
This ought not to be difficult but it's giving me fits. I've read the Python3 import chapter and searched for canonical Python project organization, to no avail.