From f189e80f23bba5b793b3792cfb13bd6d61728b68 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Thu, 12 Jul 2012 19:48:49 +0200 Subject: [PATCH] Small improvements to test_unc_path --- Lib/test/test_import.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py index ed60008df29..a38273c50a8 100644 --- a/Lib/test/test_import.py +++ b/Lib/test/test_import.py @@ -454,8 +454,8 @@ class PathsTests(unittest.TestCase): # Regression test for http://bugs.python.org/issue3677. @unittest.skipUnless(sys.platform == 'win32', 'Windows-specific') 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'") + with open(os.path.join(self.path, 'test_unc_path.py'), 'w') as f: + f.write("testdata = 'test_unc_path'") importlib.invalidate_caches() # Create the UNC path, like \\myhost\c$\foo\bar. path = os.path.abspath(self.path) @@ -464,15 +464,16 @@ class PathsTests(unittest.TestCase): drive = path[0] unc = "\\\\%s\\%s$"%(hn, drive) unc += path[2:] - sys.path.append(unc) + sys.path.insert(0, unc) try: try: - mod = __import__("test_trailing_slash") + mod = __import__("test_unc_path") except ImportError as e: - self.fail("could not import 'test_trailing_slash' from %r: %r" + self.fail("could not import 'test_unc_path' from %r: %r" % (unc, e)) - self.assertEqual(mod.testdata, 'test_trailing_slash') - unload("test_trailing_slash") + self.assertEqual(mod.testdata, 'test_unc_path') + self.assertTrue(mod.__file__.startswith(unc), mod.__file__) + unload("test_unc_path") finally: sys.path.remove(unc)