diff options
author | Brett Cannon <brett@python.org> | 2012-04-21 23:11:58 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2012-04-21 23:11:58 (GMT) |
commit | b8c0206bd4b113ea774554a608057f4ad6ebfabc (patch) | |
tree | 07d6e8fed46c973115d3ab95a8a6f3846711c63f /Lib | |
parent | 2f92389d5c477cb15a0b70e22f11e835eb077224 (diff) | |
download | cpython-b8c0206bd4b113ea774554a608057f4ad6ebfabc.zip cpython-b8c0206bd4b113ea774554a608057f4ad6ebfabc.tar.gz cpython-b8c0206bd4b113ea774554a608057f4ad6ebfabc.tar.bz2 |
Issue #14637: Fix the UNC import test under Windows to actually use
the UNC path. Also clean up sys.path and invalidate finder caches.
Thanks to Vinay Sajip for spotting the use of the wrong path.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_import.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py index ea66293..890041f 100644 --- a/Lib/test/test_import.py +++ b/Lib/test/test_import.py @@ -459,6 +459,7 @@ class PathsTests(unittest.TestCase): def test_UNC_path(self): with open(os.path.join(self.path, 'test_trailing_slash.py'), 'w') as f: f.write("testdata = 'test_trailing_slash'") + importlib.invalidate_caches() # Create the UNC path, like \\myhost\c$\foo\bar. path = os.path.abspath(self.path) import socket @@ -466,10 +467,13 @@ class PathsTests(unittest.TestCase): drive = path[0] unc = "\\\\%s\\%s$"%(hn, drive) unc += path[2:] - sys.path.append(path) - mod = __import__("test_trailing_slash") - self.assertEqual(mod.testdata, 'test_trailing_slash') - unload("test_trailing_slash") + sys.path.append(unc) + try: + mod = __import__("test_trailing_slash") + self.assertEqual(mod.testdata, 'test_trailing_slash') + unload("test_trailing_slash") + finally: + sys.path.remove(unc) class RelativeImportTests(unittest.TestCase): |