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

Method _test_partial_input

Lib/test/test_tarfile.py:3132–3150  ·  view source on GitHub ↗
(self, mode)

Source from the content-addressed store, hash-verified

3130 # on an empty or partial bzipped file.
3131
3132 def _test_partial_input(self, mode):
3133 class MyBytesIO(io.BytesIO):
3134 hit_eof = False
3135 def read(self, n):
3136 if self.hit_eof:
3137 raise AssertionError("infinite loop detected in "
3138 "tarfile.open()")
3139 self.hit_eof = self.tell() == len(self.getvalue())
3140 return super(MyBytesIO, self).read(n)
3141 def seek(self, *args):
3142 self.hit_eof = False
3143 return super(MyBytesIO, self).seek(*args)
3144
3145 data = bz2.compress(tarfile.TarInfo("foo").tobuf())
3146 for x in range(len(data) + 1):
3147 try:
3148 tarfile.open(fileobj=MyBytesIO(data[:x]), mode=mode)
3149 except tarfile.ReadError:
3150 pass # we have no interest in ReadErrors
3151
3152 def test_partial_input(self):
3153 self._test_partial_input("r")

Callers 2

test_partial_inputMethod · 0.95

Calls 5

lenFunction · 0.85
tobufMethod · 0.80
MyBytesIOClass · 0.70
compressMethod · 0.45
openMethod · 0.45

Tested by

no test coverage detected