I have the following directory structure, as recommended in the pytest docs :
setup.py src/ mypkg/ __init__.py app.py view.py tests/ __init__.py unit/ __init__.py app_test.py integration/ __init__.py app_test.py All init.py files are empty for now.
And setup.py contains:
from setuptools import setup, find_packages setup(name="mypkg", packages=find_packages()) I want to use pytest for testing.
The command i use to run tests is
pytest ./tests/unit/app_test.py How do I import app.py into app_test.py and make sure my tests can run without issue.
Ideally, I want a pythonic/clean way to resolve this, not a hack.
I've stumbled upon many questions in regards to this, such as :
How do I run all Python unit tests in a directory?
Running unittest with typical test directory structure
But somehow I can't get it to work with my use case. Can anybody pinpoint in the right direction ?