-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Open
Description
Following this section, adding from .context import sample in my tests module gives me the following error: ModuleNotFoundError: No module named '__main__.context'; '__main__' is not a package
I was able to fix it by removing the . from from .context import sample, but I suspect that's not the ideal solution. I know that the from .context import sample is a relative import statement as described in PEP 328, but I just do not understand modules, packages, absolute and relative imports, etc. enough to say what's going on here.
I tried creating ./__init__.py and ./tests/__init__.py files, but that did not help.
Finally, I tried the following:
~> git clone git@github.com:navdeep-G/samplemod.git
~> python3 samplemod/tests/test_basic.py
Traceback (most recent call last):
File "samplemod/tests/test_basic.py", line 3, in <module>
from .context import sample
ModuleNotFoundError: No module named '__main__.context'; '__main__' is not a packageI'm not alone in hitting this issue. @rileyweber13 originally reported this problem a year ago.
Metadata
Metadata
Assignees
Labels
No labels