Skip to content

Commit

Permalink
Fix path prompting when running in unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
rec committed Dec 25, 2015
1 parent 0ee96f5 commit 26a7b11
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
25 changes: 13 additions & 12 deletions code/python/echomesh/base/Path.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@

_REQUIRED_DIRECTORIES = 'asset', 'cache', 'data', 'log'

def data_path():
_set_project_path()
def data_path(**kwds):
_set_project_path(**kwds)
return _DATA_PATH

def echomesh_path():
_set_project_path()
def echomesh_path(**kwds):
_set_project_path(**kwds)
return ECHOMESH_PATH

def project_path():
_set_project_path()
def project_path(**kwds):
_set_project_path(**kwds)
return _PROJECT_PATH

def python_path():
_set_project_path()
def python_path(**kwds):
_set_project_path(**kwds)
return _PYTHON_PATH

def _possible_project(path):
Expand All @@ -62,6 +62,7 @@ def _possible_project(path):
return True

def set_project_path(project_path=None, show_error=True, prompt=True):
assert not prompt
original_path = os.path.abspath(
os.path.expanduser(project_path or os.curdir))
path = original_path
Expand Down Expand Up @@ -92,9 +93,9 @@ def set_project_path(project_path=None, show_error=True, prompt=True):
os.chdir(path)
return True

def _set_project_path():
def _set_project_path(**kwds):
if not _PROJECT_PATH:
set_project_path()
set_project_path(**kwds)

def info():
_set_project_path()
Expand All @@ -111,8 +112,8 @@ def info():
'echomesh path': ECHOMESH_PATH,
}

def fix_sys_path():
_set_project_path()
def fix_sys_path(prompt=True):
_set_project_path(prompt=prompt)
for path in reversed(PATHS):
if ECHOMESH_EXTERNALS_OVERRIDE_SYSTEM_PACKAGES:
sys.path.insert(1, path)
Expand Down
2 changes: 1 addition & 1 deletion code/python/echomesh/util/TestCase.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from echomesh.base import Path

Path.fix_sys_path()
Path.fix_sys_path(prompt=False)

import unittest

Expand Down

0 comments on commit 26a7b11

Please sign in to comment.