How to use the zopfli.zlib.compress function in zopfli

To help you get started, we’ve selected a few zopfli examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wnyc / py-zopfli / tests / tests.py View on Github external
import zopfli.gzip
import zopfli.zlib
import StringIO

class Tests(object):
    data = unittest.__doc__
    def test_reversible(self):
        data = self.data 
        self.assertEquals(self.decompress(self.compress(data)), data)

    def test_iterations_help(self):
        data = self.data
        self.assertTrue(len(self.compress(data, numiterations=1)) > len(self.compress(data, numiterations=1000)))

class ZlibTest(unittest.TestCase, Tests):
    compress = staticmethod(zopfli.zlib.compress)
    decompress = staticmethod(zlib.decompress)

class GzipTest(unittest.TestCase, Tests):

    compress = staticmethod(zopfli.gzip.compress)
    
    def decompress(self, s):
        return gzip.GzipFile(fileobj=StringIO.StringIO(s)).read()
        

if __name__ == "__main__":
    unittest.main()

zopfli

Zopfli module for python

Apache-2.0
Latest version published 2 months ago

Package Health Score

71 / 100
Full package analysis