Various tweaks to make the test work on the Mac.
authorJack Jansen <jack.jansen@cwi.nl>
Wed, 8 Jan 2003 16:37:03 +0000 (16:37 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Wed, 8 Jan 2003 16:37:03 +0000 (16:37 +0000)
Lib/test/test_zipimport.py

index 3c790eb4deaa501926c765a6471f9951e3821615..9bde605f7595e023b71ca9bfa12348dca5aabd39 100644 (file)
@@ -15,7 +15,13 @@ import zipimport
 
 def make_pyc(co, mtime):
     data = marshal.dumps(co)
-    pyc = imp.get_magic() + struct.pack("<i", mtime) + data
+    if type(mtime) is type(0.0):
+       # Mac mtimes need a bit of special casing
+       if mtime < 0x7fffffff:
+               mtime = int(mtime)
+       else:
+               mtime = int(-0x100000000L + long(mtime))
+    pyc = imp.get_magic() + struct.pack("<i", int(mtime)) + data
     return pyc
 
 NOW = time.time()
@@ -32,7 +38,10 @@ TESTMOD = "ziptestmodule"
 TESTPACK = "ziptestpackage"
 TESTPACK2 = "ziptestpackage2"
 TEMP_ZIP = os.path.abspath("junk95142.zip")
-
+if sys.platform == 'mac':
+    CURDIRPREFIX=':'
+else:
+    CURDIRPREFIX=''
 
 class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
 
@@ -59,7 +68,7 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
             if expected_ext:
                 file = mod.get_file()
                 self.assertEquals(file, os.path.join(TEMP_ZIP,
-                                  os.sep.join(modules) + expected_ext))
+                                  CURDIRPREFIX + os.sep.join(modules) + expected_ext))
         finally:
             z.close()
             os.remove(TEMP_ZIP)