summaryrefslogtreecommitdiff
path: root/Lib/test/test_tarfile.py
diff options
context:
space:
mode:
authorLars Gustäbel <lars@gustaebel.de>2015-05-27 13:05:30 +0200
committerLars Gustäbel <lars@gustaebel.de>2015-05-27 13:05:30 +0200
commit572183eaabe77257c245c688ff0536cfea10300f (patch)
tree324d8be66155cabcaa57a80656c311f60488bc9f /Lib/test/test_tarfile.py
parent8b5fb5cfc84d7733b8a62b51c61c765a73ce0108 (diff)
parent20703c696913dc8ec7d9b7153a10eda3cecce164 (diff)
downloadcpython-git-572183eaabe77257c245c688ff0536cfea10300f.tar.gz
Merge with 3.5: tarfile.open() with mode 'x' created files without an end of archive marker.
Diffstat (limited to 'Lib/test/test_tarfile.py')
-rw-r--r--Lib/test/test_tarfile.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
index 45c30aba20..66a0a61e09 100644
--- a/Lib/test/test_tarfile.py
+++ b/Lib/test/test_tarfile.py
@@ -982,6 +982,19 @@ class WriteTestBase(TarTest):
self.assertFalse(fobj.closed)
self.assertEqual(data, fobj.getvalue())
+ def test_eof_marker(self):
+ # Make sure an end of archive marker is written (two zero blocks).
+ # tarfile insists on aligning archives to a 20 * 512 byte recordsize.
+ # So, we create an archive that has exactly 10240 bytes without the
+ # marker, and has 20480 bytes once the marker is written.
+ with tarfile.open(tmpname, self.mode) as tar:
+ t = tarfile.TarInfo("foo")
+ t.size = tarfile.RECORDSIZE - tarfile.BLOCKSIZE
+ tar.addfile(t, io.BytesIO(b"a" * t.size))
+
+ with self.open(tmpname, "rb") as fobj:
+ self.assertEqual(len(fobj.read()), tarfile.RECORDSIZE * 2)
+
class WriteTest(WriteTestBase, unittest.TestCase):
@@ -1431,7 +1444,7 @@ class GNUWriteTest(unittest.TestCase):
("longlnk/" * 127) + "longlink_")
-class CreateTest(TarTest, unittest.TestCase):
+class CreateTest(WriteTestBase, unittest.TestCase):
prefix = "x:"