I want to import business code from my test folder.
I installed my code using python setup.py install
, which copy the code into the anaconda site-package folder. But I want to test my code in my dev. directory, as I don't want to constantly install my code to test it after any small change.
I am using Anaconda and Spyder IDE.
Here is my dir structure:
dev
└── myproject
├── setup.py
├── myproject
│ ├── __init__.py
│ └── myproject.py
└── test
├── __init__.py
└── test_importprojecthere.py
I took it from here: Running unittest with typical test directory structure
For now, I'm simply trying to import a function.
# dev: projectfile.py
def hello():
print('Hello world!')
Here is where I call it from.
# dev: test_importprojecthere.py
from myproject.projectfile import hello # Use installed package.
hello()
more information: