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

Method test_is_tarfile_valid

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

Source from the content-addressed store, hash-verified

412 self.assertFalse(tarfile.is_tarfile(io.BytesIO(b"invalid")))
413
414 def test_is_tarfile_valid(self):
415 # is_tarfile works on filenames
416 self.assertTrue(tarfile.is_tarfile(self.tarname))
417
418 # is_tarfile works on path-like objects
419 self.assertTrue(tarfile.is_tarfile(os_helper.FakePath(self.tarname)))
420
421 # is_tarfile works on file objects
422 with open(self.tarname, "rb") as fobj:
423 self.assertTrue(tarfile.is_tarfile(fobj))
424
425 # is_tarfile works on file-like objects
426 with open(self.tarname, "rb") as fobj:
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

Callers

nothing calls this directly

Calls 3

assertTrueMethod · 0.80
openFunction · 0.50
readMethod · 0.45

Tested by

no test coverage detected