summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_tarfile.py
diff options
context:
space:
mode:
authorLars Gustäbel <lars@gustaebel.de>2007-08-28 12:31:09 (GMT)
committerLars Gustäbel <lars@gustaebel.de>2007-08-28 12:31:09 (GMT)
commit0f4a14b56fcbd939e60f424517db61ca6f2f3885 (patch)
tree3b08b8518232c5786117dc5056baf9d10d3b31d5 /Lib/test/test_tarfile.py
parent23b8ddc110ec980e62a30d3e28678e4b75fed10e (diff)
downloadcpython-0f4a14b56fcbd939e60f424517db61ca6f2f3885.zip
cpython-0f4a14b56fcbd939e60f424517db61ca6f2f3885.tar.gz
cpython-0f4a14b56fcbd939e60f424517db61ca6f2f3885.tar.bz2
TarFile.__init__() no longer fails if no name argument is passed and
the fileobj argument has no usable name attribute (e.g. StringIO). (will backport to 2.5)
Diffstat (limited to 'Lib/test/test_tarfile.py')
-rw-r--r--Lib/test/test_tarfile.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
index 596b0ad..1f08258 100644
--- a/Lib/test/test_tarfile.py
+++ b/Lib/test/test_tarfile.py
@@ -141,11 +141,25 @@ class UstarReadTest(ReadTest):
class MiscReadTest(ReadTest):
- def test_no_filename(self):
+ def test_no_name_argument(self):
fobj = open(self.tarname, "rb")
tar = tarfile.open(fileobj=fobj, mode=self.mode)
self.assertEqual(tar.name, os.path.abspath(fobj.name))
+ def test_no_name_attribute(self):
+ data = open(self.tarname, "rb").read()
+ fobj = StringIO.StringIO(data)
+ self.assertRaises(AttributeError, getattr, fobj, "name")
+ tar = tarfile.open(fileobj=fobj, mode=self.mode)
+ self.assertEqual(tar.name, None)
+
+ def test_empty_name_attribute(self):
+ data = open(self.tarname, "rb").read()
+ fobj = StringIO.StringIO(data)
+ fobj.name = ""
+ tar = tarfile.open(fileobj=fobj, mode=self.mode)
+ self.assertEqual(tar.name, None)
+
def test_fail_comp(self):
# For Gzip and Bz2 Tests: fail with a ReadError on an uncompressed file.
if self.mode == "r:":