[Python-checkins] r42166 - python/trunk/Lib/test/test_zipimport.py

tim.peters python-checkins at python.org
Mon Jan 23 23:19:25 CET 2006


Author: tim.peters
Date: Mon Jan 23 23:19:24 2006
New Revision: 42166

Modified:
   python/trunk/Lib/test/test_zipimport.py
Log:
Repaired new test failures on Windows:

- The path separator isn't "/" on Windows.

- Leaving behind a read-only file causes cascades
  of bogus failures on Windows.


Modified: python/trunk/Lib/test/test_zipimport.py
==============================================================================
--- python/trunk/Lib/test/test_zipimport.py	(original)
+++ python/trunk/Lib/test/test_zipimport.py	Mon Jan 23 23:19:24 2006
@@ -30,6 +30,9 @@
     pyc = imp.get_magic() + struct.pack("<i", int(mtime)) + data
     return pyc
 
+def module_path_to_dotted_name(path):
+    return path.replace(os.sep, '.')
+
 NOW = time.time()
 test_pyc = make_pyc(test_co, NOW)
 
@@ -206,7 +209,7 @@
             self.assertEquals(zi.is_package(packdir2 + TESTMOD), False)
 
             mod_name = packdir2 + TESTMOD
-            mod = __import__(mod_name.replace('/', '.'))
+            mod = __import__(module_path_to_dotted_name(mod_name))
             self.assertEquals(zi.get_source(TESTPACK), None)
             self.assertEquals(zi.get_source(mod_name), None)
         finally:
@@ -276,8 +279,14 @@
     def testFileUnreadable(self):
         test_support.unlink(TESTMOD)
         fd = os.open(TESTMOD, os.O_CREAT, 000)
-        os.close(fd)
-        self.assertZipFailure(TESTMOD)
+        try:
+            os.close(fd)
+            self.assertZipFailure(TESTMOD)
+        finally:
+            # If we leave "the read-only bit" set on Windows, nothing can
+            # delete TESTMOD, and later tests suffer bogus failures.
+            os.chmod(TESTMOD, 0666)
+            test_support.unlink(TESTMOD)
 
     def testNotZipFile(self):
         test_support.unlink(TESTMOD)


More information about the Python-checkins mailing list