(self)
| 3450 | |
| 3451 | class NoneInfoTests_Misc(unittest.TestCase): |
| 3452 | def test_add(self): |
| 3453 | # When addfile() encounters None metadata, it raises a ValueError |
| 3454 | bio = io.BytesIO() |
| 3455 | for tarformat in (tarfile.USTAR_FORMAT, tarfile.GNU_FORMAT, |
| 3456 | tarfile.PAX_FORMAT): |
| 3457 | with self.subTest(tarformat=tarformat): |
| 3458 | tar = tarfile.open(fileobj=bio, mode='w', format=tarformat) |
| 3459 | tarinfo = tar.gettarinfo(tarname) |
| 3460 | try: |
| 3461 | with open(tarname, 'rb') as f: |
| 3462 | tar.addfile(tarinfo, f) |
| 3463 | except Exception: |
| 3464 | if tarformat == tarfile.USTAR_FORMAT: |
| 3465 | # In the old, limited format, adding might fail for |
| 3466 | # reasons like the UID being too large |
| 3467 | pass |
| 3468 | else: |
| 3469 | raise |
| 3470 | else: |
| 3471 | for attr_name in ('mtime', 'mode', 'uid', 'gid', |
| 3472 | 'uname', 'gname'): |
| 3473 | with self.subTest(attr_name=attr_name): |
| 3474 | replaced = tarinfo.replace(**{attr_name: None}) |
| 3475 | with self.assertRaisesRegex(ValueError, |
| 3476 | f"{attr_name}"): |
| 3477 | with open(tarname, 'rb') as f: |
| 3478 | tar.addfile(replaced, f) |
| 3479 | |
| 3480 | def test_list(self): |
| 3481 | # Change some metadata to None, then compare list() output |
nothing calls this directly
no test coverage detected