summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_tarfile.py
diff options
context:
space:
mode:
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 8a59879..10498bf 100644
--- a/Lib/test/test_tarfile.py
+++ b/Lib/test/test_tarfile.py
@@ -140,11 +140,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 = io.BytesIO(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 = io.BytesIO(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:":