[Python-checkins] python/dist/src/Lib/test test_tarfile.py, 1.16, 1.16.2.1
loewis@users.sourceforge.net
loewis at users.sourceforge.net
Sat Aug 27 12:08:31 CEST 2005
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29574/Lib/test
Modified Files:
Tag: release24-maint
test_tarfile.py
Log Message:
Patch #1168594: set sizes of non-regular files to zero. Fixes #1167128.
Index: test_tarfile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_tarfile.py,v
retrieving revision 1.16
retrieving revision 1.16.2.1
diff -u -d -r1.16 -r1.16.2.1
--- test_tarfile.py 25 Oct 2004 03:19:41 -0000 1.16
+++ test_tarfile.py 27 Aug 2005 10:08:21 -0000 1.16.2.1
@@ -208,6 +208,40 @@
else:
self.dst.addfile(tarinfo, f)
+class WriteSize0Test(BaseTest):
+ mode = 'w'
+
+ def setUp(self):
+ self.tmpdir = dirname()
+ self.dstname = tmpname()
+ self.dst = tarfile.open(self.dstname, "w")
+
+ def tearDown(self):
+ self.dst.close()
+
+ def test_file(self):
+ path = os.path.join(self.tmpdir, "file")
+ file(path, "w")
+ tarinfo = self.dst.gettarinfo(path)
+ self.assertEqual(tarinfo.size, 0)
+ file(path, "w").write("aaa")
+ tarinfo = self.dst.gettarinfo(path)
+ self.assertEqual(tarinfo.size, 3)
+
+ def test_directory(self):
+ path = os.path.join(self.tmpdir, "directory")
+ os.mkdir(path)
+ tarinfo = self.dst.gettarinfo(path)
+ self.assertEqual(tarinfo.size, 0)
+
+ def test_symlink(self):
+ if hasattr(os, "symlink"):
+ path = os.path.join(self.tmpdir, "symlink")
+ os.symlink("link_target", path)
+ tarinfo = self.dst.gettarinfo(path)
+ self.assertEqual(tarinfo.size, 0)
+
+
class WriteStreamTest(WriteTest):
sep = '|'
@@ -366,6 +400,7 @@
ReadTest,
ReadStreamTest,
WriteTest,
+ WriteSize0Test,
WriteStreamTest,
WriteGNULongTest,
]
More information about the Python-checkins
mailing list