summaryrefslogtreecommitdiff
path: root/Lib/test/test_tarfile.py
diff options
context:
space:
mode:
authorLars Gustäbel <lars@gustaebel.de>2008-05-27 12:39:23 +0000
committerLars Gustäbel <lars@gustaebel.de>2008-05-27 12:39:23 +0000
commitb1a54a353021f3d478e1d9e667cef0fa92507c36 (patch)
tree968765c627007ccae0350e85264f16c0dcecdda6 /Lib/test/test_tarfile.py
parent0902cac4b355e98184b0e435f9bb7e24ed68f6a2 (diff)
downloadcpython-git-b1a54a353021f3d478e1d9e667cef0fa92507c36.tar.gz
Do not close external file objects passed to tarfile.open(mode='w:bz2')
when the TarFile is closed.
Diffstat (limited to 'Lib/test/test_tarfile.py')
-rw-r--r--Lib/test/test_tarfile.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
index f0e755e869..f3bc12d24b 100644
--- a/Lib/test/test_tarfile.py
+++ b/Lib/test/test_tarfile.py
@@ -529,7 +529,19 @@ class PaxReadTest(LongnameTest):
self.assertEqual(float(tarinfo.pax_headers["ctime"]), 1041808783.0)
-class WriteTest(unittest.TestCase):
+class WriteTestBase(unittest.TestCase):
+ # Put all write tests in here that are supposed to be tested
+ # in all possible mode combinations.
+
+ def test_fileobj_no_close(self):
+ fobj = StringIO.StringIO()
+ tar = tarfile.open(fileobj=fobj, mode=self.mode)
+ tar.addfile(tarfile.TarInfo("foo"))
+ tar.close()
+ self.assert_(fobj.closed is False, "external fileobjs must never closed")
+
+
+class WriteTest(WriteTestBase):
mode = "w:"
@@ -652,7 +664,7 @@ class WriteTest(unittest.TestCase):
shutil.rmtree(tempdir)
-class StreamWriteTest(unittest.TestCase):
+class StreamWriteTest(WriteTestBase):
mode = "w|"