MCPcopy Index your code
hub / github.com/python/cpython / test_ustar_limits

Method test_ustar_limits

Lib/test/test_tarfile.py:2650–2679  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2648class LimitsTest(unittest.TestCase):
2649
2650 def test_ustar_limits(self):
2651 # 100 char name
2652 tarinfo = tarfile.TarInfo("0123456789" * 10)
2653 tarinfo.tobuf(tarfile.USTAR_FORMAT)
2654
2655 # 101 char name that cannot be stored
2656 tarinfo = tarfile.TarInfo("0123456789" * 10 + "0")
2657 self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT)
2658
2659 # 256 char name with a slash at pos 156
2660 tarinfo = tarfile.TarInfo("123/" * 62 + "longname")
2661 tarinfo.tobuf(tarfile.USTAR_FORMAT)
2662
2663 # 256 char name that cannot be stored
2664 tarinfo = tarfile.TarInfo("1234567/" * 31 + "longname")
2665 self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT)
2666
2667 # 512 char name
2668 tarinfo = tarfile.TarInfo("123/" * 126 + "longname")
2669 self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT)
2670
2671 # 512 char linkname
2672 tarinfo = tarfile.TarInfo("longlink")
2673 tarinfo.linkname = "123/" * 126 + "longname"
2674 self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT)
2675
2676 # uid > 8 digits
2677 tarinfo = tarfile.TarInfo("name")
2678 tarinfo.uid = 0o10000000
2679 self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT)
2680
2681 def test_gnu_limits(self):
2682 tarinfo = tarfile.TarInfo("123/" * 126 + "longname")

Callers

nothing calls this directly

Calls 2

tobufMethod · 0.95
assertRaisesMethod · 0.45

Tested by

no test coverage detected