mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Will backport to 2.4.
This commit is contained in:
parent
9e34c04732
commit
5dbdc59577
3 changed files with 49 additions and 14 deletions
|
@ -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,
|
||||
]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue