I am trying to build a Python package/library for the first time. So far I have these files:
src
Accentizer2
__init__.py
Accentizer.py
Annotation.py
test
test_1.py
File contents:
Accentizer.py:
from Annotation import Annotation # this is where the error occurs
class Accentizer:
x = 10
Annotation.py:
class Annotation:
Variants = []
test_1.py:
from src.Accentizer2.Accentizer import Accentizer
When I run test_1.py, I get the following error:
Traceback (most recent call last):
File "..\tests\test_1.py", line 1, in <module>
from src.Accentizer2.Accentizer import Accentizer
File "..\src\Accentizer2\Accentizer.py", line 1, in <module>
from Annotation import Annotation
ModuleNotFoundError: No module named 'Annotation'
When I run Accentizer.py, it runs ok.
What am I missing? What is the conventional way of linking tests to code under test?
Changing the import statement in Accentizer.py to the line below fixes the error:
from src.Accentizer2.Accentizer import Accentizer
But then I get the error 'src is not a module name' after I build and install the Accentizer2 package and try to import it in another project.