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

Method test_empty_tarfile

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

Source from the content-addressed store, hash-verified

439 self.assertEqual(file_like.tell(), 0)
440
441 def test_empty_tarfile(self):
442 # Test for issue6123: Allow opening empty archives.
443 # This test checks if tarfile.open() is able to open an empty tar
444 # archive successfully. Note that an empty tar archive is not the
445 # same as an empty file!
446 with tarfile.open(tmpname, self.mode.replace("r", "w")):
447 pass
448 try:
449 tar = tarfile.open(tmpname, self.mode)
450 tar.getnames()
451 except tarfile.ReadError:
452 self.fail("tarfile.open() failed on empty archive")
453 else:
454 self.assertListEqual(tar.getmembers(), [])
455 finally:
456 tar.close()
457
458 def test_non_existent_tarfile(self):
459 # Test for issue11513: prevent non-existent gzipped tarfiles raising

Callers

nothing calls this directly

Calls 7

getnamesMethod · 0.80
assertListEqualMethod · 0.80
getmembersMethod · 0.80
openMethod · 0.45
replaceMethod · 0.45
failMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected