[Tutor] import issues
James Hartley
jjhartley at gmail.com
Tue Jan 9 13:06:22 EST 2024
I admit that I have not internalized how Python's import system works yet.
Given the following directory structure:
+-project
|
+-src
| |
| +-__init__.py
| +-foo.py
|
+-tests
|
+-test_foo.py
Currently, __init__.py is empty. What needs to be placed in __init__.py
and test_foo.py in order for pytest to execute all tests in test_foo.py?
pytest is being executed while in the project directory. With:
from foo import Foo
--or--
from src.foo import Foo
defined in test_foo.py, pytest reports "ModuleNotFoundError: No module
named 'src'".
Any and all comments would be appreciated. Any links to online sources
would also be appreciated. Thanks!
j
More information about the Tutor
mailing list