MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_readinto1

Method test_readinto1

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected