當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。