MCPcopy Index your code
hub / github.com/python/cpython / test_readinto1

Method test_readinto1

Lib/test/test_gzip.py:158–176  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

156 self.assertEqual(buf, large_data)
157
158 def test_readinto1(self):
159 # 10MB of uncompressible data to ensure multiple reads
160 large_data = os.urandom(10 * 2**20)
161 with gzip.GzipFile(self.filename, 'wb') as f:
162 f.write(large_data)
163
164 nread = 0
165 buf = bytearray(len(large_data))
166 memview = memoryview(buf) # Simplifies slicing
167 with gzip.GzipFile(self.filename, 'r') as f:
168 for count in range(200):
169 nbytes = f.readinto1(memview[nread:])
170 if not nbytes:
171 break
172 nread += nbytes
173 self.assertEqual(f.tell(), nread)
174 self.assertEqual(buf, large_data)
175 # readinto1() should require multiple loops
176 self.assertGreater(count, 1)
177
178 @bigmemtest(size=_4G, memuse=1)
179 def test_read_large(self, size):

Callers

nothing calls this directly

Calls 5

assertGreaterMethod · 0.80
writeMethod · 0.45
readinto1Method · 0.45
assertEqualMethod · 0.45
tellMethod · 0.45

Tested by

no test coverage detected