changeset: 76454:0356103cde28 user: Brett Cannon date: Sat Apr 21 19:11:58 2012 -0400 files: Lib/test/test_import.py description: 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. diff -r 024660a2faaa -r 0356103cde28 Lib/test/test_import.py --- a/Lib/test/test_import.py Sat Apr 21 18:55:51 2012 -0400 +++ b/Lib/test/test_import.py Sat Apr 21 19:11:58 2012 -0400 @@ -459,6 +459,7 @@ 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 @@ 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):

AltStyle によって変換されたページ (->オリジナル) /