• Home
  • Raw
  • Download

Lines Matching full:gzip

1 """Test script for the gzip module.
17 gzip = support.import_module('gzip') variable
26 data2 = b"""/* zlibmodule.c -- gzip-compatible data compression */
27 /* See http://www.gzip.org/zlib/
59 with gzip.GzipFile(self.filename, 'w'+mode) as f:
62 with gzip.GzipFile(self.filename, 'r'+mode) as f:
66 with gzip.GzipFile(self.filename, 'wb') as f:
81 with gzip.GzipFile(filename, 'w') as f:
84 with gzip.GzipFile(filename, 'a') as f:
86 with gzip.GzipFile(filename) as f:
110 with gzip.GzipFile(self.filename, 'wb') as f:
116 with gzip.GzipFile(self.filename, 'rb') as f:
122 with gzip.GzipFile(self.filename, 'r') as f:
130 with gzip.GzipFile(self.filename, 'r') as f:
145 compressed = gzip.compress(data1, compresslevel=1)
146 f = gzip.GzipFile(fileobj=io.BytesIO(compressed), mode='rb')
155 f = gzip.GzipFile(self.filename, 'r')
167 f = gzip.GzipFile(self.filename, 'w')
180 with gzip.GzipFile(self.filename, 'ab') as f:
183 with gzip.GzipFile(self.filename, 'rb') as f:
191 with gzip.GzipFile(self.filename, 'wb', 9) as f:
194 with gzip.GzipFile(self.filename, "ab", 9) as f: # append
198 with gzip.GzipFile(self.filename, "rb") as zgfile:
207 with gzip.GzipFile(self.filename, 'xb') as f:
209 with gzip.GzipFile(self.filename, 'rb') as f:
212 gzip.GzipFile(self.filename, 'xb')
219 with gzip.GzipFile(self.filename, 'rb') as f:
229 with gzip.GzipFile(self.filename, 'rb') as f:
241 with gzip.GzipFile(self.filename, 'rb') as f:
244 with gzip.GzipFile(self.filename, 'rb') as f:
253 with gzip.GzipFile(self.filename) as f:
272 with gzip.GzipFile(self.filename) as f:
280 with gzip.GzipFile(self.filename, 'w') as f:
287 with gzip.GzipFile(self.filename, 'r') as f:
290 with gzip.GzipFile(self.filename, 'x') as f:
295 with gzip.GzipFile(self.filename, mode) as f:
301 with gzip.GzipFile(self.filename, 'rb') as f:
307 with gzip.GzipFile(self.filename, 'w', mtime = mtime) as fWrite:
309 with gzip.GzipFile(self.filename) as fRead:
319 with gzip.GzipFile(self.filename, 'w', mtime = mtime) as fWrite:
326 self.assertEqual(idBytes, b'\x1f\x8b') # gzip ID
352 # However, the gzip module defaults to storing the name of the output
383 fWrite = gzip.GzipFile(self.filename, 'w', compresslevel=level)
393 with gzip.GzipFile(self.filename, "wb") as f:
395 f = gzip.GzipFile(self.filename, "rb")
405 with gzip.GzipFile(self.filename, "wb") as f:
413 with gzip.GzipFile(self.filename, "wb") as f:
420 with gzip.GzipFile(self.filename, "rb") as f:
425 self.assertTrue(issubclass(gzip.BadGzipFile, OSError))
430 with gzip.GzipFile(self.filename, 'r') as file:
431 self.assertRaises(gzip.BadGzipFile, file.readlines)
436 with gzip.GzipFile(fileobj=buf, mode="wb") as f:
440 with gzip.GzipFile(fileobj=buf, mode="rb") as f:
445 with gzip.GzipFile(self.filename, "wb") as f:
453 with gzip.GzipFile(self.filename, "rb") as f:
469 with gzip.GzipFile(self.filename, 'r') as f:
478 with gzip.GzipFile(fileobj=f, mode="w") as g:
482 gzip.GzipFile(self.filename, "wb").close()
484 with gzip.GzipFile(fileobj=f, mode='r') as g:
485 self.assertEqual(g.mode, gzip.READ)
486 with gzip.GzipFile(fileobj=f, mode='w') as g:
487 self.assertEqual(g.mode, gzip.WRITE)
488 with gzip.GzipFile(fileobj=f, mode='a') as g:
489 self.assertEqual(g.mode, gzip.WRITE)
490 with gzip.GzipFile(fileobj=f, mode='x') as g:
491 self.assertEqual(g.mode, gzip.WRITE)
493 gzip.GzipFile(fileobj=f, mode='z')
496 with gzip.GzipFile(fileobj=f) as g:
497 self.assertEqual(g.mode, gzip.READ)
503 g = gzip.GzipFile(fileobj=f)
505 self.assertEqual(g.mode, gzip.WRITE)
513 with gzip.GzipFile(bytes_filename, "wb") as f:
515 with gzip.GzipFile(bytes_filename, "rb") as f:
518 with gzip.GzipFile(str_filename, "rb") as f:
523 bomb = gzip.compress(b'\0' * int(2e6), compresslevel=9)
527 decomp = gzip.GzipFile(fileobj=bomb)
538 datac = gzip.compress(data, *args)
540 with gzip.GzipFile(fileobj=io.BytesIO(datac), mode="rb") as f:
548 datac = gzip.compress(data, *args, mtime=mtime)
550 with gzip.GzipFile(fileobj=io.BytesIO(datac), mode="rb") as f:
557 with gzip.GzipFile(fileobj=buf, mode="wb") as f:
559 self.assertEqual(gzip.decompress(buf.getvalue()), data)
561 datac = gzip.compress(data)
562 self.assertEqual(gzip.decompress(datac), data)
567 truncated = gzip.compress(data)[:-8]
568 with gzip.GzipFile(fileobj=io.BytesIO(truncated)) as f:
570 with gzip.GzipFile(fileobj=io.BytesIO(truncated)) as f:
575 with gzip.GzipFile(fileobj=io.BytesIO(truncated[:i])) as f:
579 # Gzip data with an extra field
583 with gzip.GzipFile(fileobj=io.BytesIO(gzdata)) as f:
588 with gzip.open(self.filename, "wb") as f:
590 with gzip.open(self.filename, "rb") as f:
597 with gzip.open(self.filename, "wb") as f:
600 file_data = gzip.decompress(f.read())
603 with gzip.open(self.filename, "rb") as f:
606 with gzip.open(self.filename, "ab") as f:
609 file_data = gzip.decompress(f.read())
613 gzip.open(self.filename, "xb")
615 with gzip.open(self.filename, "xb") as f:
618 file_data = gzip.decompress(f.read())
623 with gzip.open(filename, "wb") as f:
625 with gzip.open(filename, "ab") as f:
627 with gzip.open(filename) as f:
634 with gzip.open(self.filename, "w") as f:
637 file_data = gzip.decompress(f.read())
640 with gzip.open(self.filename, "r") as f:
643 with gzip.open(self.filename, "a") as f:
646 file_data = gzip.decompress(f.read())
650 gzip.open(self.filename, "x")
652 with gzip.open(self.filename, "x") as f:
655 file_data = gzip.decompress(f.read())
661 with gzip.open(self.filename, "wt") as f:
664 file_data = gzip.decompress(f.read()).decode("ascii")
666 with gzip.open(self.filename, "rt") as f:
668 with gzip.open(self.filename, "at") as f:
671 file_data = gzip.decompress(f.read()).decode("ascii")
677 compressed = gzip.compress(uncompressed_bytes)
678 with gzip.open(io.BytesIO(compressed), "r") as f:
680 with gzip.open(io.BytesIO(compressed), "rb") as f:
682 with gzip.open(io.BytesIO(compressed), "rt") as f:
688 gzip.open(123.456)
690 gzip.open(self.filename, "wbt")
692 gzip.open(self.filename, "xbt")
694 gzip.open(self.filename, "rb", encoding="utf-8")
696 gzip.open(self.filename, "rb", errors="ignore")
698 gzip.open(self.filename, "rb", newline="\n")
704 with gzip.open(self.filename, "wt", encoding="utf-16") as f:
707 file_data = gzip.decompress(f.read()).decode("utf-16")
709 with gzip.open(self.filename, "rt", encoding="utf-16") as f:
714 with gzip.open(self.filename, "wb") as f:
716 with gzip.open(self.filename, "rt", encoding="ascii", errors="ignore") \
723 with gzip.open(self.filename, "wt", newline="\n") as f:
725 with gzip.open(self.filename, "rt", newline="\r") as f:
743 data = b'This is a simple test with gzip'
747 with gzip.GzipFile(fileobj=bytes_io, mode='wb') as gzip_file:
750 args = sys.executable, '-m', 'gzip', '-d'
762 with gzip.open(gzipname, mode='wb') as fp:
764 rc, out, err = assert_python_ok('-m', 'gzip', '-d', gzipname)
775 rc, out, err = assert_python_ok('-m', 'gzip', '-d', 'thisisatest.out')
782 args = sys.executable, '-m', 'gzip'
798 rc, out, err = assert_python_ok('-m', 'gzip', local_testgzip)
815 rc, out, err = assert_python_ok('-m', 'gzip', compress_level, local_testgzip)
824 rc, out, err = assert_python_failure('-m', 'gzip', '--fast', '--best')
829 rc, out, err = assert_python_failure('-m', 'gzip', '--fast', '-d')