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

Method test_eof_marker

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

Source from the content-addressed store, hash-verified

1417 self.assertEqual(data, fobj.getvalue())
1418
1419 def test_eof_marker(self):
1420 # Make sure an end of archive marker is written (two zero blocks).
1421 # tarfile insists on aligning archives to a 20 * 512 byte recordsize.
1422 # So, we create an archive that has exactly 10240 bytes without the
1423 # marker, and has 20480 bytes once the marker is written.
1424 with tarfile.open(tmpname, self.mode) as tar:
1425 t = tarfile.TarInfo("foo")
1426 t.size = tarfile.RECORDSIZE - tarfile.BLOCKSIZE
1427 tar.addfile(t, io.BytesIO(b"a" * t.size))
1428
1429 with self.open(tmpname, "rb") as fobj:
1430 self.assertEqual(len(fobj.read()), tarfile.RECORDSIZE * 2)
1431
1432
1433class WriteTest(WriteTestBase, unittest.TestCase):

Callers

nothing calls this directly

Calls 4

addfileMethod · 0.80
openMethod · 0.45
assertEqualMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected