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

Method test_compresslevel_metadata

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

Source from the content-addressed store, hash-verified

406 self.test_metadata()
407
408 def test_compresslevel_metadata(self):
409 # see RFC 1952: http://www.faqs.org/rfcs/rfc1952.html
410 # specifically, discussion of XFL in section 2.3.1
411 cases = [
412 ('fast', 1, b'\x04'),
413 ('best', 9, b'\x02'),
414 ('tradeoff', 6, b'\x00'),
415 ]
416 xflOffset = 8
417
418 for (name, level, expectedXflByte) in cases:
419 with self.subTest(name):
420 fWrite = gzip.GzipFile(self.filename, 'w', compresslevel=level)
421 with fWrite:
422 fWrite.write(data1)
423 with open(self.filename, 'rb') as fRead:
424 fRead.seek(xflOffset)
425 xflByte = fRead.read(1)
426 self.assertEqual(xflByte, expectedXflByte)
427
428 def test_with_open(self):
429 # GzipFile supports the context management protocol

Callers

nothing calls this directly

Calls 6

writeMethod · 0.95
openFunction · 0.50
subTestMethod · 0.45
seekMethod · 0.45
readMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected