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.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
index f18dcc0..c2abc7e 100644
--- a/Lib/test/test_tarfile.py
+++ b/Lib/test/test_tarfile.py
@@ -1612,6 +1612,12 @@ class WriteTest(WriteTestBase, unittest.TestCase):
pax_headers={'non': 'empty'})
self.assertFalse(f.closed)
+ def test_missing_fileobj(self):
+ with tarfile.open(tmpname, self.mode) as tar:
+ tarinfo = tar.gettarinfo(tarname)
+ with self.assertRaises(ValueError):
+ tar.addfile(tarinfo)
+
class GzipWriteTest(GzipTest, WriteTest):
pass
@@ -3283,7 +3289,8 @@ class NoneInfoTests_Misc(unittest.TestCase):
tar = tarfile.open(fileobj=bio, mode='w', format=tarformat)
tarinfo = tar.gettarinfo(tarname)
try:
- tar.addfile(tarinfo)
+ with open(tarname, 'rb') as f:
+ tar.addfile(tarinfo, f)
except Exception:
if tarformat == tarfile.USTAR_FORMAT:
# In the old, limited format, adding might fail for
@@ -3298,7 +3305,8 @@ class NoneInfoTests_Misc(unittest.TestCase):
replaced = tarinfo.replace(**{attr_name: None})
with self.assertRaisesRegex(ValueError,
f"{attr_name}"):
- tar.addfile(replaced)
+ with open(tarname, 'rb') as f:
+ tar.addfile(replaced, f)
def test_list(self):
# Change some metadata to None, then compare list() output