I developed a solution with the following structure:
my_package/
my_test_data/
test.py
In test.py
I can easily import my_package (from my_package import my_class
). This is very useful in my IDE of choice where I can write test cases, execute them and eventually set breakpoints in the code being tested where needed.
The fine structure, ready for distribution, changed to:
my_package/
tests/
my_test_data/
test.py
This is ok if someone wants to test that what's been installed works fine. Test references the installed version of my_package. The problem is that during development I need to reference my_package
from the development folder, so that I can test the live version I'm developing and eventually step into it for debugging purposes. I tried to solve the problem with relative import from .my_package import my_class
, from .. my_package import my_class
and other combinations but I get this Exception:
ValueError: Attempted relative import in non-package
Any help?