diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2010-01-03 22:37:40 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-01-03 22:37:40 (GMT) |
commit | b1f8835b213411d059d0e2ba4b78125328afeee6 (patch) | |
tree | 42cf60ff63d11840481e1ee373fa213c950a99cc /Lib/test/test_gzip.py | |
parent | a81d881e136021a84656620b3bf11dfa8b0556ec (diff) | |
download | cpython-b1f8835b213411d059d0e2ba4b78125328afeee6.zip cpython-b1f8835b213411d059d0e2ba4b78125328afeee6.tar.gz cpython-b1f8835b213411d059d0e2ba4b78125328afeee6.tar.bz2 |
Merged revisions 77288 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77288 | antoine.pitrou | 2010-01-03 23:29:56 +0100 (dim., 03 janv. 2010) | 5 lines
Issue #7471: Improve the performance of GzipFile's buffering mechanism,
and make it implement the `io.BufferedIOBase` ABC to allow for further
speedups by wrapping it in an `io.BufferedReader`. Patch by Nir Aides.
........
Diffstat (limited to 'Lib/test/test_gzip.py')
-rw-r--r-- | Lib/test/test_gzip.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_gzip.py b/Lib/test/test_gzip.py index fa91dc0..320adfd 100644 --- a/Lib/test/test_gzip.py +++ b/Lib/test/test_gzip.py @@ -5,6 +5,7 @@ import unittest from test import support import os +import io import struct gzip = support.import_module('gzip') @@ -80,6 +81,16 @@ class TestGzip(unittest.TestCase): zgfile.close() self.assertEquals(contents, b'a'*201) + def test_buffered_reader(self): + # Issue #7471: a GzipFile can be wrapped in a BufferedReader for + # performance. + self.test_write() + + f = gzip.GzipFile(self.filename, 'rb') + with io.BufferedReader(f) as r: + lines = [line for line in r] + + self.assertEqual(lines, 50 * data1.splitlines(True)) def test_readline(self): self.test_write() |