summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_zipimport.py
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2006-01-23 22:19:24 (GMT)
committerTim Peters <tim.peters@gmail.com>2006-01-23 22:19:24 (GMT)
commit68f2d000e9666487afd0198681c14cc3fdc9742a (patch)
tree7315f92fb46d57bd2d1cfcd718dc93f224b7022d /Lib/test/test_zipimport.py
parentcaa94bd48465ed65cfa4b44fc576e57abd71e578 (diff)
downloadcpython-68f2d000e9666487afd0198681c14cc3fdc9742a.zip
cpython-68f2d000e9666487afd0198681c14cc3fdc9742a.tar.gz
cpython-68f2d000e9666487afd0198681c14cc3fdc9742a.tar.bz2
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.
Diffstat (limited to 'Lib/test/test_zipimport.py')
-rw-r--r--Lib/test/test_zipimport.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/Lib/test/test_zipimport.py b/Lib/test/test_zipimport.py
index f20f472..eb7cbf6 100644
--- a/Lib/test/test_zipimport.py
+++ b/Lib/test/test_zipimport.py
@@ -30,6 +30,9 @@ def make_pyc(co, mtime):
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 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
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 @@ class BadFileZipImportTestCase(unittest.TestCase):
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)