summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_tarfile.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2006-12-06 22:21:18 (GMT)
committerGeorg Brandl <georg@python.org>2006-12-06 22:21:18 (GMT)
commit87fa5594790fda836c8a59708de60513430c0328 (patch)
treef8f2676661834478a3ef49f76c28f71084b01d34 /Lib/test/test_tarfile.py
parent0a286d0b538478e490e6f85ae3339e4bd6846953 (diff)
downloadcpython-87fa5594790fda836c8a59708de60513430c0328.zip
cpython-87fa5594790fda836c8a59708de60513430c0328.tar.gz
cpython-87fa5594790fda836c8a59708de60513430c0328.tar.bz2
Patch #1610437: fix a tarfile bug with long filename headers.
Diffstat (limited to 'Lib/test/test_tarfile.py')
-rw-r--r--Lib/test/test_tarfile.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
index ee83cbe..2685d67 100644
--- a/Lib/test/test_tarfile.py
+++ b/Lib/test/test_tarfile.py
@@ -388,13 +388,6 @@ class WriteGNULongTest(unittest.TestCase):
is tested as well.
"""
- def setUp(self):
- self.tar = tarfile.open(tmpname(), "w")
- self.tar.posix = False
-
- def tearDown(self):
- self.tar.close()
-
def _length(self, s):
blocks, remainder = divmod(len(s) + 1, 512)
if remainder:
@@ -423,12 +416,23 @@ class WriteGNULongTest(unittest.TestCase):
tarinfo.linkname = link
tarinfo.type = tarfile.LNKTYPE
- self.tar.addfile(tarinfo)
+ tar = tarfile.open(tmpname(), "w")
+ tar.posix = False
+ tar.addfile(tarinfo)
v1 = self._calc_size(name, link)
- v2 = self.tar.offset
+ v2 = tar.offset
self.assertEqual(v1, v2, "GNU longname/longlink creation failed")
+ tar.close()
+
+ tar = tarfile.open(tmpname())
+ member = tar.next()
+ self.failIf(member is None, "unable to read longname member")
+ self.assert_(tarinfo.name == member.name and \
+ tarinfo.linkname == member.linkname, \
+ "unable to read longname member")
+
def test_longname_1023(self):
self._test(("longnam/" * 127) + "longnam")