Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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()
def do_compress(self, filename, compressed_filename):
import zopfli.gzip
with open(filename, 'rb') as f_in, \
open(compressed_filename, 'wb') as f_out:
f_out.write(zopfli.gzip.compress(f_in.read()))
def compress(self, path, file):
return ContentFile(zopfli.compress(file.read()))