I inherited an existing project with a layout that looks similar to this:
.
├── src
│ ├── __init__.py
│ └── greetings.py
├── tests
│ └── test-greetings.py
The other two files are:
# greetings.py
def hello():
return 'hello'
# test-greetings.py
import pytest
import sys
sys.path.append('../src')
from greetings import hello
def test_hello():
assert hello() == 'hello'
This works, i.e. I can run pytest test-greetings.py
from the tests directory but I would like to avoid using the sys.path.append('../src')
line. Is there another way to achieve this without changing the project layout?