Show More
@@ -614,10 +614,18 b' def filefind(filename, path_dirs=None):' | |||||
614 | ------- |
|
614 | ------- | |
615 | Raises :exc:`IOError` or returns absolute path to file. |
|
615 | Raises :exc:`IOError` or returns absolute path to file. | |
616 | """ |
|
616 | """ | |
|
617 | ||||
|
618 | # If paths are quoted, abspath gets confused, strip them... | |||
|
619 | filename = filename.strip('"').strip("'") | |||
|
620 | # If the input is an absolute path, just check it exists | |||
|
621 | if os.path.isabs(filename) and os.path.isfile(filename): | |||
|
622 | return filename | |||
|
623 | ||||
617 | if path_dirs is None: |
|
624 | if path_dirs is None: | |
618 | path_dirs = ("",) |
|
625 | path_dirs = ("",) | |
619 | elif isinstance(path_dirs, basestring): |
|
626 | elif isinstance(path_dirs, basestring): | |
620 | path_dirs = (path_dirs,) |
|
627 | path_dirs = (path_dirs,) | |
|
628 | ||||
621 | for path in path_dirs: |
|
629 | for path in path_dirs: | |
622 | if path == '.': path = os.getcwd() |
|
630 | if path == '.': path = os.getcwd() | |
623 | testname = expand_path(os.path.join(path, filename)) |
|
631 | testname = expand_path(os.path.join(path, filename)) | |
@@ -883,6 +891,7 b' def get_ipython_dir():' | |||||
883 | """ |
|
891 | """ | |
884 | ipdir_def = '.ipython' |
|
892 | ipdir_def = '.ipython' | |
885 | home_dir = get_home_dir() |
|
893 | home_dir = get_home_dir() | |
|
894 | #import pdb; pdb.set_trace() # dbg | |||
886 | ipdir = os.environ.get( |
|
895 | ipdir = os.environ.get( | |
887 | 'IPYTHON_DIR', os.environ.get( |
|
896 | 'IPYTHON_DIR', os.environ.get( | |
888 | 'IPYTHONDIR', os.path.join(home_dir, ipdir_def) |
|
897 | 'IPYTHONDIR', os.path.join(home_dir, ipdir_def) |
@@ -55,7 +55,7 b' env = os.environ' | |||||
55 | TEST_FILE_PATH = split(abspath(__file__))[0] |
|
55 | TEST_FILE_PATH = split(abspath(__file__))[0] | |
56 | TMP_TEST_DIR = tempfile.mkdtemp() |
|
56 | TMP_TEST_DIR = tempfile.mkdtemp() | |
57 | HOME_TEST_DIR = join(TMP_TEST_DIR, "home_test_dir") |
|
57 | HOME_TEST_DIR = join(TMP_TEST_DIR, "home_test_dir") | |
58 |
IP_TEST_DIR = join(HOME_TEST_DIR,' |
|
58 | IP_TEST_DIR = join(HOME_TEST_DIR,'.ipython') | |
59 | # |
|
59 | # | |
60 | # Setup/teardown functions/decorators |
|
60 | # Setup/teardown functions/decorators | |
61 | # |
|
61 | # | |
@@ -88,19 +88,17 b' def setup_environment():' | |||||
88 | each testfunction needs a pristine environment. |
|
88 | each testfunction needs a pristine environment. | |
89 | """ |
|
89 | """ | |
90 | global oldstuff, platformstuff |
|
90 | global oldstuff, platformstuff | |
91 |
oldstuff = (env.copy(), os.name, genutils.get_home_dir, IPython.__file__ |
|
91 | oldstuff = (env.copy(), os.name, genutils.get_home_dir, IPython.__file__) | |
92 |
|
92 | |||
93 | if os.name == 'nt': |
|
93 | if os.name == 'nt': | |
94 | platformstuff = (wreg.OpenKey, wreg.QueryValueEx,) |
|
94 | platformstuff = (wreg.OpenKey, wreg.QueryValueEx,) | |
95 |
|
95 | |||
96 | # Remove both spellings of env variables if present |
|
96 | ||
97 | env.pop('IPYTHON_DIR', None) |
|
|||
98 | env.pop('IPYTHONDIR', None) |
|
|||
99 |
|
||||
100 | def teardown_environment(): |
|
97 | def teardown_environment(): | |
101 | """Restore things that were remebered by the setup_environment function |
|
98 | """Restore things that were remebered by the setup_environment function | |
102 | """ |
|
99 | """ | |
103 | (oldenv, os.name, genutils.get_home_dir, IPython.__file__,) = oldstuff |
|
100 | (oldenv, os.name, genutils.get_home_dir, IPython.__file__,) = oldstuff | |
|
101 | ||||
104 | for key in env.keys(): |
|
102 | for key in env.keys(): | |
105 | if key not in oldenv: |
|
103 | if key not in oldenv: | |
106 | del env[key] |
|
104 | del env[key] | |
@@ -233,6 +231,8 b' def test_get_ipython_dir_2():' | |||||
233 | """test_get_ipython_dir_2, Testcase to see if we can call get_ipython_dir without Exceptions.""" |
|
231 | """test_get_ipython_dir_2, Testcase to see if we can call get_ipython_dir without Exceptions.""" | |
234 | genutils.get_home_dir = lambda : "someplace" |
|
232 | genutils.get_home_dir = lambda : "someplace" | |
235 | os.name = "posix" |
|
233 | os.name = "posix" | |
|
234 | env.pop('IPYTHON_DIR', None) | |||
|
235 | env.pop('IPYTHONDIR', None) | |||
236 | ipdir = genutils.get_ipython_dir() |
|
236 | ipdir = genutils.get_ipython_dir() | |
237 | nt.assert_equal(ipdir, os.path.join("someplace", ".ipython")) |
|
237 | nt.assert_equal(ipdir, os.path.join("someplace", ".ipython")) | |
238 |
|
238 |
General Comments 0
You need to be logged in to leave comments.
Login now