Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Added environment override for dipy_home variable #1233

Merged
merged 3 commits into from May 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion dipy/data/fetcher.py
Expand Up @@ -23,7 +23,10 @@


# Set a user-writeable file-system location to put files:
dipy_home = pjoin(os.path.expanduser('~'), '.dipy')
if 'DIPY_HOME' in os.environ:
dipy_home = os.environ['DIPY_HOME']
else:
dipy_home = pjoin(os.path.expanduser('~'), '.dipy')

# The URL to the University of Washington Researchworks repository:
UW_RW_URL = \
Expand Down
20 changes: 20 additions & 0 deletions dipy/data/tests/test_fetcher.py
Expand Up @@ -104,3 +104,23 @@ def test_fetch_data():
server.shutdown()
# change to original working directory
os.chdir(current_dir)

def test_dipy_home():
test_path = 'TEST_PATH'
if 'DIPY_HOME' in os.environ:
old_home = os.environ['DIPY_HOME']
del os.environ['DIPY_HOME']
else:
old_home = None

reload(fetcher)

npt.assert_string_equal(fetcher.dipy_home,
op.join(os.path.expanduser('~'), '.dipy'))
os.environ['DIPY_HOME'] = test_path
reload(fetcher)
npt.assert_string_equal(fetcher.dipy_home, test_path)

# return to previous state
if old_home:
os.environ['DIPY_HOME'] = old_home