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

Method test_detect_stream_bz2

Lib/test/test_tarfile.py:1049–1061  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1047
1048class Bz2DetectReadTest(Bz2Test, DetectReadTest):
1049 def test_detect_stream_bz2(self):
1050 # Originally, tarfile's stream detection looked for the string
1051 # "BZh91" at the start of the file. This is incorrect because
1052 # the '9' represents the blocksize (900,000 bytes). If the file was
1053 # compressed using another blocksize autodetection fails.
1054 with open(tarname, "rb") as fobj:
1055 data = fobj.read()
1056
1057 # Compress with blocksize 100,000 bytes, the file starts with "BZh11".
1058 with bz2.BZ2File(tmpname, "wb", compresslevel=1) as fobj:
1059 fobj.write(data)
1060
1061 self._testfunc_file(tmpname, "r|*")
1062
1063class LzmaDetectReadTest(LzmaTest, DetectReadTest):
1064 pass

Callers

nothing calls this directly

Calls 4

_testfunc_fileMethod · 0.80
openFunction · 0.50
readMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected