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

Method test_is_tarfile_keeps_position

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

Source from the content-addressed store, hash-verified

427 self.assertTrue(tarfile.is_tarfile(io.BytesIO(fobj.read())))
428
429 def test_is_tarfile_keeps_position(self):
430 # Test for issue44289: tarfile.is_tarfile() modifies
431 # file object's current position
432 with open(self.tarname, "rb") as fobj:
433 tarfile.is_tarfile(fobj)
434 self.assertEqual(fobj.tell(), 0)
435
436 with open(self.tarname, "rb") as fobj:
437 file_like = io.BytesIO(fobj.read())
438 tarfile.is_tarfile(file_like)
439 self.assertEqual(file_like.tell(), 0)
440
441 def test_empty_tarfile(self):
442 # Test for issue6123: Allow opening empty archives.

Callers

nothing calls this directly

Calls 5

tellMethod · 0.95
openFunction · 0.50
assertEqualMethod · 0.45
tellMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected