Skip to content

Commit a255634

Browse files
committed
Ignore unrelated errors in NoneInfoTests_Misc.test_add
1 parent 0474842 commit a255634

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

Lib/test/test_tarfile.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3177,14 +3177,23 @@ def test_add(self):
31773177
with self.subTest(tarformat=tarformat):
31783178
tar = tarfile.open(fileobj=bio, mode='w', format=tarformat)
31793179
tarinfo = tar.gettarinfo(tarname)
3180-
tar.addfile(tarinfo)
3181-
for attr_name in ('mtime', 'mode', 'uid', 'gid',
3182-
'uname', 'gname'):
3183-
with self.subTest(attr_name=attr_name):
3184-
replaced = tarinfo.replace(**{attr_name: None})
3185-
with self.assertRaisesRegex(ValueError,
3186-
f"{attr_name}"):
3187-
tar.addfile(replaced)
3180+
try:
3181+
tar.addfile(tarinfo)
3182+
except Exception:
3183+
if tarformat == tarfile.USTAR_FORMAT:
3184+
# In the old, limited format, adding might fail for
3185+
# reasons like the UID being too large
3186+
pass
3187+
else:
3188+
raise
3189+
else:
3190+
for attr_name in ('mtime', 'mode', 'uid', 'gid',
3191+
'uname', 'gname'):
3192+
with self.subTest(attr_name=attr_name):
3193+
replaced = tarinfo.replace(**{attr_name: None})
3194+
with self.assertRaisesRegex(ValueError,
3195+
f"{attr_name}"):
3196+
tar.addfile(replaced)
31883197

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

0 commit comments

Comments
 (0)