##// END OF EJS Templates
Fixed broken test in :mod:`IPython.utils.tests.test_path`.
Brian Granger -
Show More
1 NO CONTENT: modified file
@@ -26,15 +26,7 b' from nose import with_setup'
26 26 import IPython
27 27 from IPython.testing import decorators as dec
28 28 from IPython.testing.decorators import skip_if_not_win32
29 from IPython.utils.path import (
30 get_home_dir,
31 HomeDirError,
32 get_ipython_dir,
33 get_ipython_package_dir,
34 get_ipython_module_path,
35 filefind,
36 get_long_path_name
37 )
29 from IPython.utils import path
38 30
39 31 # Platform-dependent imports
40 32 try:
@@ -68,6 +60,7 b' def setup():'
68 60 # problem because that exception is only defined on Windows...
69 61 os.makedirs(IP_TEST_DIR)
70 62
63
71 64 def teardown():
72 65 """Teardown testenvironment for the module:
73 66
@@ -87,7 +80,7 b' def setup_environment():'
87 80 each testfunction needs a pristine environment.
88 81 """
89 82 global oldstuff, platformstuff
90 oldstuff = (env.copy(), os.name, get_home_dir, IPython.__file__)
83 oldstuff = (env.copy(), os.name, path.get_home_dir, IPython.__file__)
91 84
92 85 if os.name == 'nt':
93 86 platformstuff = (wreg.OpenKey, wreg.QueryValueEx,)
@@ -121,9 +114,10 b' def test_get_home_dir_1():'
121 114 #fake filename for IPython.__init__
122 115 IPython.__file__ = abspath(join(HOME_TEST_DIR, "Lib/IPython/__init__.py"))
123 116
124 home_dir = get_home_dir()
117 path.home_dir = get_home_dir()
125 118 nt.assert_equal(home_dir, abspath(HOME_TEST_DIR))
126 119
120
127 121 @skip_if_not_win32
128 122 @with_environment
129 123 def test_get_home_dir_2():
@@ -133,24 +127,27 b' def test_get_home_dir_2():'
133 127 #fake filename for IPython.__init__
134 128 IPython.__file__ = abspath(join(HOME_TEST_DIR, "Library.zip/IPython/__init__.py")).lower()
135 129
136 home_dir = get_home_dir()
130 home_dir = path.get_home_dir()
137 131 nt.assert_equal(home_dir, abspath(HOME_TEST_DIR).lower())
138 132
133
139 134 @with_environment
140 135 def test_get_home_dir_3():
141 136 """Testcase $HOME is set, then use its value as home directory."""
142 137 env["HOME"] = HOME_TEST_DIR
143 home_dir = get_home_dir()
138 home_dir = path.get_home_dir()
144 139 nt.assert_equal(home_dir, env["HOME"])
145 140
141
146 142 @with_environment
147 143 def test_get_home_dir_4():
148 """Testcase $HOME is not set, os=='poix'.
144 """Testcase $HOME is not set, os=='posix'.
149 145 This should fail with HomeDirError"""
150 146
151 147 os.name = 'posix'
152 148 if 'HOME' in env: del env['HOME']
153 nt.assert_raises(HomeDirError, get_home_dir)
149 nt.assert_raises(path.HomeDirError, path.get_home_dir)
150
154 151
155 152 @skip_if_not_win32
156 153 @with_environment
@@ -162,9 +159,10 b' def test_get_home_dir_5():'
162 159 if 'HOME' in env: del env['HOME']
163 160 env['HOMEDRIVE'], env['HOMEPATH'] = os.path.splitdrive(HOME_TEST_DIR)
164 161
165 home_dir = get_home_dir()
162 home_dir = path.get_home_dir()
166 163 nt.assert_equal(home_dir, abspath(HOME_TEST_DIR))
167 164
165
168 166 @skip_if_not_win32
169 167 @with_environment
170 168 def test_get_home_dir_6():
@@ -178,9 +176,10 b' def test_get_home_dir_6():'
178 176 env['HOMEDRIVE'], env['HOMEPATH'] = os.path.abspath(TEST_FILE_PATH), "DOES NOT EXIST"
179 177 env["USERPROFILE"] = abspath(HOME_TEST_DIR)
180 178
181 home_dir = get_home_dir()
179 home_dir = path.get_home_dir()
182 180 nt.assert_equal(home_dir, abspath(HOME_TEST_DIR))
183 181
182
184 183 # Should we stub wreg fully so we can run the test on all platforms?
185 184 @skip_if_not_win32
186 185 @with_environment
@@ -206,7 +205,7 b' def test_get_home_dir_7():'
206 205 wreg.OpenKey = OpenKey
207 206 wreg.QueryValueEx = QueryValueEx
208 207
209 home_dir = get_home_dir()
208 home_dir = path.get_home_dir()
210 209 nt.assert_equal(home_dir, abspath(HOME_TEST_DIR))
211 210
212 211
@@ -214,47 +213,48 b' def test_get_home_dir_7():'
214 213 def test_get_ipython_dir_1():
215 214 """test_get_ipython_dir_1, Testcase to see if we can call get_ipython_dir without Exceptions."""
216 215 env['IPYTHON_DIR'] = "someplace/.ipython"
217 ipdir = get_ipython_dir()
216 ipdir = path.get_ipython_dir()
218 217 nt.assert_equal(ipdir, "someplace/.ipython")
219 218
220 219
221 220 @with_environment
222 221 def test_get_ipython_dir_2():
223 222 """test_get_ipython_dir_2, Testcase to see if we can call get_ipython_dir without Exceptions."""
224 get_home_dir = lambda : "someplace"
223 path.get_home_dir = lambda : "someplace"
225 224 os.name = "posix"
226 225 env.pop('IPYTHON_DIR', None)
227 226 env.pop('IPYTHONDIR', None)
228 ipdir = get_ipython_dir()
227 ipdir = path.get_ipython_dir()
229 228 nt.assert_equal(ipdir, os.path.join("someplace", ".ipython"))
230 229
231 230
232 231 def test_filefind():
233 232 """Various tests for filefind"""
234 233 f = tempfile.NamedTemporaryFile()
235 print 'fname:',f.name
236 alt_dirs = get_ipython_dir()
237 t = filefind(f.name, alt_dirs)
238 print 'found:',t
234 # print 'fname:',f.name
235 alt_dirs = path.get_ipython_dir()
236 t = path.filefind(f.name, alt_dirs)
237 # print 'found:',t
239 238
240 239
241 240 def test_get_ipython_package_dir():
242 ipdir = get_ipython_package_dir()
241 ipdir = path.get_ipython_package_dir()
243 242 nt.assert_true(os.path.isdir(ipdir))
244 243
244
245 245 def test_get_ipython_module_path():
246 ipapp_path = get_ipython_module_path('IPython.core.ipapp')
246 ipapp_path = path.get_ipython_module_path('IPython.core.ipapp')
247 247 nt.assert_true(os.path.isfile(ipapp_path))
248 248
249
249 250 @dec.skip_if_not_win32
250 251 def test_get_long_path_name_win32():
251 p = get_long_path_name('c:\\docume~1')
252 p = path.get_long_path_name('c:\\docume~1')
252 253 nt.assert_equals(p,u'c:\\Documents and Settings')
253 254
254 255
255 256 @dec.skip_win32
256 257 def test_get_long_path_name():
257 p = get_long_path_name('/usr/local')
258 p = path.get_long_path_name('/usr/local')
258 259 nt.assert_equals(p,'/usr/local')
259 260
260
General Comments 0
You need to be logged in to leave comments. Login now