]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #14637: Fix the UNC import test under Windows to actually use
authorBrett Cannon <brett@python.org>
Sat, 21 Apr 2012 23:11:58 +0000 (19:11 -0400)
committerBrett Cannon <brett@python.org>
Sat, 21 Apr 2012 23:11:58 +0000 (19:11 -0400)
the UNC path. Also clean up sys.path and invalidate finder caches.

Thanks to Vinay Sajip for spotting the use of the wrong path.

Lib/test/test_import.py

index ea66293d90481acfe3e72ffb2c224d0fae63812e..890041f0d78014184467b2c65185f99956e1c837 100644 (file)
@@ -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):