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) 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 if __name__ == "__main__": test_support.run_unittest(UncompressedZipImportTestCase) test_support.run_unittest(CompressedZipImportTestCase)