当前位置: 首页>>代码示例>>Python>>正文


Python zlib.py方法代码示例

本文整理汇总了Python中zlib.py方法的典型用法代码示例。如果您正苦于以下问题:Python zlib.py方法的具体用法?Python zlib.py怎么用?Python zlib.py使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在zlib的用法示例。


在下文中一共展示了zlib.py方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testAFakeZlib

# 需要导入模块: import zlib [as 别名]
# 或者: from zlib import py [as 别名]
def testAFakeZlib(self):
        #
        # This could cause a stack overflow before: importing zlib.py
        # from a compressed archive would cause zlib to be imported
        # which would find zlib.py in the archive, which would... etc.
        #
        # This test *must* be executed first: it must be the first one
        # to trigger zipimport to import zlib (zipimport caches the
        # zlib.decompress function object, after which the problem being
        # tested here wouldn't be a problem anymore...
        # (Hence the 'A' in the test method name: to make it the first
        # item in a list sorted by name, like unittest.makeSuite() does.)
        #
        # This test fails on platforms on which the zlib module is
        # statically linked, but the problem it tests for can't
        # occur in that case (builtin modules are always found first),
        # so we'll simply skip it then. Bug #765456.
        #
        if "zlib" in sys.builtin_module_names:
            return
        if "zlib" in sys.modules:
            del sys.modules["zlib"]
        files = {"zlib.py": (NOW, test_src)}
        try:
            self.doTest(".py", files, "zlib")
        except ImportError:
            if self.compression != ZIP_DEFLATED:
                self.fail("expected test to not raise ImportError")
        else:
            if self.compression != ZIP_STORED:
                self.fail("expected test to raise ImportError") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:33,代码来源:test_zipimport.py

示例2: testPy

# 需要导入模块: import zlib [as 别名]
# 或者: from zlib import py [as 别名]
def testPy(self):
        files = {TESTMOD + ".py": (NOW, test_src)}
        self.doTest(".py", files, TESTMOD) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:test_zipimport.py

示例3: testBoth

# 需要导入模块: import zlib [as 别名]
# 或者: from zlib import py [as 别名]
def testBoth(self):
        files = {TESTMOD + ".py": (NOW, test_src),
                 TESTMOD + pyc_ext: (NOW, test_pyc)}
        self.doTest(pyc_ext, files, TESTMOD) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:test_zipimport.py

示例4: testEmptyPy

# 需要导入模块: import zlib [as 别名]
# 或者: from zlib import py [as 别名]
def testEmptyPy(self):
        files = {TESTMOD + ".py": (NOW, "")}
        self.doTest(None, files, TESTMOD) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:test_zipimport.py

示例5: testBadMagic

# 需要导入模块: import zlib [as 别名]
# 或者: from zlib import py [as 别名]
def testBadMagic(self):
        # make pyc magic word invalid, forcing loading from .py
        m0 = ord(test_pyc[0])
        m0 ^= 0x04  # flip an arbitrary bit
        badmagic_pyc = chr(m0) + test_pyc[1:]
        files = {TESTMOD + ".py": (NOW, test_src),
                 TESTMOD + pyc_ext: (NOW, badmagic_pyc)}
        self.doTest(".py", files, TESTMOD) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:test_zipimport.py

示例6: testBadMTime

# 需要导入模块: import zlib [as 别名]
# 或者: from zlib import py [as 别名]
def testBadMTime(self):
        t3 = ord(test_pyc[7])
        t3 ^= 0x02  # flip the second bit -- not the first as that one
                    # isn't stored in the .py's mtime in the zip archive.
        badtime_pyc = test_pyc[:7] + chr(t3) + test_pyc[8:]
        files = {TESTMOD + ".py": (NOW, test_src),
                 TESTMOD + pyc_ext: (NOW, badtime_pyc)}
        self.doTest(".py", files, TESTMOD) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:test_zipimport.py

示例7: testImport_WithStuff

# 需要导入模块: import zlib [as 别名]
# 或者: from zlib import py [as 别名]
def testImport_WithStuff(self):
        # try importing from a zipfile which contains additional
        # stuff at the beginning of the file
        files = {TESTMOD + ".py": (NOW, test_src)}
        self.doTest(".py", files, TESTMOD,
                    stuff="Some Stuff"*31) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:8,代码来源:test_zipimport.py

示例8: testGetSource

# 需要导入模块: import zlib [as 别名]
# 或者: from zlib import py [as 别名]
def testGetSource(self):
        files = {TESTMOD + ".py": (NOW, test_src)}
        self.doTest(".py", files, TESTMOD, call=self.assertModuleSource) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:test_zipimport.py

示例9: testGetCompiledSource

# 需要导入模块: import zlib [as 别名]
# 或者: from zlib import py [as 别名]
def testGetCompiledSource(self):
        pyc = make_pyc(compile(test_src, "<???>", "exec"), NOW)
        files = {TESTMOD + ".py": (NOW, test_src),
                 TESTMOD + pyc_ext: (NOW, pyc)}
        self.doTest(pyc_ext, files, TESTMOD, call=self.assertModuleSource) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:test_zipimport.py

示例10: runDoctest

# 需要导入模块: import zlib [as 别名]
# 或者: from zlib import py [as 别名]
def runDoctest(self, callback):
        files = {TESTMOD + ".py": (NOW, test_src),
                 "xyz.txt": (NOW, ">>> log.append(True)\n")}
        self.doTest(".py", files, TESTMOD, call=callback) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:test_zipimport.py


注:本文中的zlib.py方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。