import sys import os import marshal import imp import struct import time import zlib # implied prerequisite from zipfile import ZipFile, ZipInfo, ZIP_STORED, ZIP_DEFLATED from test import test_support from test.test_importhooks import ImportHooksBaseTestCase, test_src, test_co import zipimport def make_pyc(co, mtime): data = marshal.dumps(co) 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("", "exec"), NOW) files = {TESTMOD + pyc_ext: (NOW, pyc), "some.data": (NOW, "some data")} self.doTest(pyc_ext, files, TESTMOD) class CompressedZipImportTestCase(UncompressedZipImportTestCase): compression = ZIP_DEFLATED def test_main(): test_support.run_unittest(UncompressedZipImportTestCase) test_support.run_unittest(CompressedZipImportTestCase) if __name__ == "__main__": test_main()