Skip to content

Commit

Permalink
Ignore unrelated errors in NoneInfoTests_Misc.test_add
Browse files Browse the repository at this point in the history
  • Loading branch information
encukou committed Apr 20, 2023
1 parent 0474842 commit a255634
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions Lib/test/test_tarfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3177,14 +3177,23 @@ def test_add(self):
with self.subTest(tarformat=tarformat):
tar = tarfile.open(fileobj=bio, mode='w', format=tarformat)
tarinfo = tar.gettarinfo(tarname)
tar.addfile(tarinfo)
for attr_name in ('mtime', 'mode', 'uid', 'gid',
'uname', 'gname'):
with self.subTest(attr_name=attr_name):
replaced = tarinfo.replace(**{attr_name: None})
with self.assertRaisesRegex(ValueError,
f"{attr_name}"):
tar.addfile(replaced)
try:
tar.addfile(tarinfo)
except Exception:
if tarformat == tarfile.USTAR_FORMAT:
# In the old, limited format, adding might fail for
# reasons like the UID being too large
pass
else:
raise
else:
for attr_name in ('mtime', 'mode', 'uid', 'gid',
'uname', 'gname'):
with self.subTest(attr_name=attr_name):
replaced = tarinfo.replace(**{attr_name: None})
with self.assertRaisesRegex(ValueError,
f"{attr_name}"):
tar.addfile(replaced)

def test_list(self):
# Change some metadata to None, then compare list() output
Expand Down

0 comments on commit a255634

Please sign in to comment.