Created
March 29, 2013 19:02
-
-
Save mattnorris/5272868 to your computer and use it in GitHub Desktop.
Update the system path in a Python script to find "local" files within a project. This is especially helpful for unit testing.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Given the following directory structure: | |
project-name | |
docs | |
scripts | |
src | |
lib | |
test | |
input | |
output | |
unit | |
Where the current file resides in 'test/unit'... | |
""" | |
# Get the relevant paths of the modules and tests. | |
CURR_PATH = os.path.dirname(__file__) | |
MODULE_PATH = os.path.normpath(os.path.join(CURR_PATH, '../../src/')) | |
OUTPUT_PATH = os.path.normpath(os.path.join(CURR_PATH, '../output')) | |
INPUT_PATH = os.path.normpath(os.path.join(CURR_PATH, '../input')) | |
# Update the system path so we can find the modules we want to test. | |
sys.path.append(MODULE_PATH) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment