Show More
@@ -113,7 +113,7 def test_get_home_dir_1(): | |||
|
113 | 113 | IPython.__file__ = abspath(join(HOME_TEST_DIR, "Lib/IPython/__init__.py")) |
|
114 | 114 | |
|
115 | 115 | home_dir = path.get_home_dir() |
|
116 |
|
|
|
116 | assert home_dir == unfrozen | |
|
117 | 117 | |
|
118 | 118 | |
|
119 | 119 | @skip_if_not_win32 |
@@ -127,7 +127,7 def test_get_home_dir_2(): | |||
|
127 | 127 | IPython.__file__ = abspath(join(HOME_TEST_DIR, "Library.zip/IPython/__init__.py")).lower() |
|
128 | 128 | |
|
129 | 129 | home_dir = path.get_home_dir(True) |
|
130 |
|
|
|
130 | assert home_dir == unfrozen | |
|
131 | 131 | |
|
132 | 132 | |
|
133 | 133 | @skip_win32_py38 |
@@ -137,7 +137,7 def test_get_home_dir_3(): | |||
|
137 | 137 | env["HOME"] = HOME_TEST_DIR |
|
138 | 138 | home_dir = path.get_home_dir(True) |
|
139 | 139 | # get_home_dir expands symlinks |
|
140 |
|
|
|
140 | assert home_dir == os.path.realpath(env["HOME"]) | |
|
141 | 141 | |
|
142 | 142 | |
|
143 | 143 | @with_environment |
@@ -181,7 +181,7 def test_get_home_dir_8(): | |||
|
181 | 181 | with patch.object(wreg, 'OpenKey', return_value=key()), \ |
|
182 | 182 | patch.object(wreg, 'QueryValueEx', return_value=[abspath(HOME_TEST_DIR)]): |
|
183 | 183 | home_dir = path.get_home_dir() |
|
184 |
|
|
|
184 | assert home_dir == abspath(HOME_TEST_DIR) | |
|
185 | 185 | |
|
186 | 186 | @with_environment |
|
187 | 187 | def test_get_xdg_dir_0(): |
@@ -195,7 +195,7 def test_get_xdg_dir_0(): | |||
|
195 | 195 | env.pop('IPYTHONDIR', None) |
|
196 | 196 | env.pop('XDG_CONFIG_HOME', None) |
|
197 | 197 | |
|
198 |
|
|
|
198 | assert path.get_xdg_dir() == os.path.join("somewhere", ".config") | |
|
199 | 199 | |
|
200 | 200 | |
|
201 | 201 | @with_environment |
@@ -208,7 +208,7 def test_get_xdg_dir_1(): | |||
|
208 | 208 | env.pop('IPYTHON_DIR', None) |
|
209 | 209 | env.pop('IPYTHONDIR', None) |
|
210 | 210 | env.pop('XDG_CONFIG_HOME', None) |
|
211 |
|
|
|
211 | assert path.get_xdg_dir() is None | |
|
212 | 212 | |
|
213 | 213 | @with_environment |
|
214 | 214 | def test_get_xdg_dir_2(): |
@@ -224,7 +224,7 def test_get_xdg_dir_2(): | |||
|
224 | 224 | if not os.path.exists(cfgdir): |
|
225 | 225 | os.makedirs(cfgdir) |
|
226 | 226 | |
|
227 |
|
|
|
227 | assert path.get_xdg_dir() == cfgdir | |
|
228 | 228 | |
|
229 | 229 | @with_environment |
|
230 | 230 | def test_get_xdg_dir_3(): |
@@ -240,7 +240,7 def test_get_xdg_dir_3(): | |||
|
240 | 240 | if not os.path.exists(cfgdir): |
|
241 | 241 | os.makedirs(cfgdir) |
|
242 | 242 | |
|
243 |
|
|
|
243 | assert path.get_xdg_dir() is None | |
|
244 | 244 | |
|
245 | 245 | def test_filefind(): |
|
246 | 246 | """Various tests for filefind""" |
@@ -263,13 +263,13 def test_get_long_path_name_win32(): | |||
|
263 | 263 | # Test to see if the short path evaluates correctly. |
|
264 | 264 | short_path = os.path.join(tmpdir, 'THISIS~1') |
|
265 | 265 | evaluated_path = path.get_long_path_name(short_path) |
|
266 |
|
|
|
266 | assert evaluated_path.lower() == long_path.lower() | |
|
267 | 267 | |
|
268 | 268 | |
|
269 | 269 | @dec.skip_win32 |
|
270 | 270 | def test_get_long_path_name(): |
|
271 |
p = path.get_long_path_name( |
|
|
272 |
|
|
|
271 | p = path.get_long_path_name("/usr/local") | |
|
272 | assert p == "/usr/local" | |
|
273 | 273 | |
|
274 | 274 | |
|
275 | 275 | class TestRaiseDeprecation(unittest.TestCase): |
@@ -300,18 +300,18 class TestRaiseDeprecation(unittest.TestCase): | |||
|
300 | 300 | @with_environment |
|
301 | 301 | def test_get_py_filename(): |
|
302 | 302 | os.chdir(TMP_TEST_DIR) |
|
303 |
with make_tempfile( |
|
|
304 |
|
|
|
305 |
|
|
|
306 |
with make_tempfile( |
|
|
307 |
|
|
|
308 |
nt.assert_raises(IOError, path.get_py_filename, |
|
|
309 |
nt.assert_raises(IOError, path.get_py_filename, |
|
|
310 |
nt.assert_raises(IOError, path.get_py_filename, |
|
|
311 |
true_fn = |
|
|
303 | with make_tempfile("foo.py"): | |
|
304 | assert path.get_py_filename("foo.py") == "foo.py" | |
|
305 | assert path.get_py_filename("foo") == "foo.py" | |
|
306 | with make_tempfile("foo"): | |
|
307 | assert path.get_py_filename("foo") == "foo" | |
|
308 | nt.assert_raises(IOError, path.get_py_filename, "foo.py") | |
|
309 | nt.assert_raises(IOError, path.get_py_filename, "foo") | |
|
310 | nt.assert_raises(IOError, path.get_py_filename, "foo.py") | |
|
311 | true_fn = "foo with spaces.py" | |
|
312 | 312 | with make_tempfile(true_fn): |
|
313 |
|
|
|
314 |
|
|
|
313 | assert path.get_py_filename("foo with spaces") == true_fn | |
|
314 | assert path.get_py_filename("foo with spaces.py") == true_fn | |
|
315 | 315 | nt.assert_raises(IOError, path.get_py_filename, '"foo with spaces.py"') |
|
316 | 316 | nt.assert_raises(IOError, path.get_py_filename, "'foo with spaces.py'") |
|
317 | 317 | |
@@ -361,8 +361,7 class TestShellGlob(unittest.TestCase): | |||
|
361 | 361 | def check_match(self, patterns, matches): |
|
362 | 362 | with self.in_tempdir(): |
|
363 | 363 | # glob returns unordered list. that's why sorted is required. |
|
364 |
|
|
|
365 | sorted(matches)) | |
|
364 | assert sorted(path.shellglob(patterns)) == sorted(matches) | |
|
366 | 365 | |
|
367 | 366 | def common_cases(self): |
|
368 | 367 | return [ |
@@ -397,12 +396,13 class TestShellGlob(unittest.TestCase): | |||
|
397 | 396 | yield (self.check_match, patterns, matches) |
|
398 | 397 | |
|
399 | 398 | |
|
399 | # TODO : pytest.mark.parametrise once nose is gone. | |
|
400 | 400 | def test_unescape_glob(): |
|
401 |
|
|
|
402 |
|
|
|
403 |
|
|
|
404 |
|
|
|
405 |
|
|
|
401 | assert path.unescape_glob(r"\*\[\!\]\?") == "*[!]?" | |
|
402 | assert path.unescape_glob(r"\\*") == r"\*" | |
|
403 | assert path.unescape_glob(r"\\\*") == r"\*" | |
|
404 | assert path.unescape_glob(r"\\a") == r"\a" | |
|
405 | assert path.unescape_glob(r"\a") == r"\a" | |
|
406 | 406 | |
|
407 | 407 | |
|
408 | 408 | @onlyif_unicode_paths |
@@ -431,17 +431,19 class TestLinkOrCopy(unittest.TestCase): | |||
|
431 | 431 | return os.path.join(self.tempdir.name, *args) |
|
432 | 432 | |
|
433 | 433 | def assert_inode_not_equal(self, a, b): |
|
434 | nt.assert_not_equal(os.stat(a).st_ino, os.stat(b).st_ino, | |
|
435 | "%r and %r do reference the same indoes" %(a, b)) | |
|
434 | assert ( | |
|
435 | os.stat(a).st_ino != os.stat(b).st_ino | |
|
436 | ), "%r and %r do reference the same indoes" % (a, b) | |
|
436 | 437 | |
|
437 | 438 | def assert_inode_equal(self, a, b): |
|
438 | nt.assert_equal(os.stat(a).st_ino, os.stat(b).st_ino, | |
|
439 | "%r and %r do not reference the same indoes" %(a, b)) | |
|
439 | assert ( | |
|
440 | os.stat(a).st_ino == os.stat(b).st_ino | |
|
441 | ), "%r and %r do not reference the same indoes" % (a, b) | |
|
440 | 442 | |
|
441 | 443 | def assert_content_equal(self, a, b): |
|
442 | 444 | with open(a) as a_f: |
|
443 | 445 | with open(b) as b_f: |
|
444 |
|
|
|
446 | assert a_f.read() == b_f.read() | |
|
445 | 447 | |
|
446 | 448 | @skip_win32 |
|
447 | 449 | def test_link_successful(self): |
@@ -489,4 +491,4 class TestLinkOrCopy(unittest.TestCase): | |||
|
489 | 491 | path.link_or_copy(self.src, dst) |
|
490 | 492 | path.link_or_copy(self.src, dst) |
|
491 | 493 | self.assert_inode_equal(self.src, dst) |
|
492 |
|
|
|
494 | assert sorted(os.listdir(self.tempdir.name)) == ["src", "target"] |
General Comments 0
You need to be logged in to leave comments.
Login now