diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2005-08-27 10:07:56 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2005-08-27 10:07:56 (GMT) |
commit | 5dbdc59577e0eff59d0ec7a58f0510ef6f4f2051 (patch) | |
tree | f51af9a38db96196bd3059030bf9125aa2533bdd /Lib/test/test_tarfile.py | |
parent | 9e34c047325651853a95f95e538582a4f6d5b7f6 (diff) | |
download | cpython-5dbdc59577e0eff59d0ec7a58f0510ef6f4f2051.zip cpython-5dbdc59577e0eff59d0ec7a58f0510ef6f4f2051.tar.gz cpython-5dbdc59577e0eff59d0ec7a58f0510ef6f4f2051.tar.bz2 |
Patch #1168594: set sizes of non-regular files to zero. Fixes #1167128.
Will backport to 2.4.
Diffstat (limited to 'Lib/test/test_tarfile.py')
-rw-r--r-- | Lib/test/test_tarfile.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py index cc5e505..66409cd 100644 --- a/Lib/test/test_tarfile.py +++ b/Lib/test/test_tarfile.py @@ -230,6 +230,40 @@ class WriteTest(BaseTest): 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 = '|' @@ -399,6 +433,7 @@ def test_main(): ReadAsteriskTest, ReadStreamAsteriskTest, WriteTest, + WriteSize0Test, WriteStreamTest, WriteGNULongTest, ] |