Assume a Python package (e.g., MyPackage) that consists of several modules (e.g., MyModule1.py and MyModule2.py) and a set of unittests (e.g., in MyPackage_test.py).
.
├── MyPackage
│   ├── __init__.py
│   ├── MyModule1.py
│   └── MyModule2.py
├── README.md
├── requirements.txt
├── setup.py
└── tests
    └── MyPackage_test.py
I would like to import functions of MyModule1.py within the unittests of MyPackage_test.py. Specifically, I would like to import the functions both before as well as after package installation via setup.py install MyPackage.
Currently, I am using two separate commands, depending on the state before or after package installation:
# BEFORE
import sys, os
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'MyPackage'))
# AFTER
import MyPackage
Can this be done with a single command?
 
    