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

Method test_longname_file_not_directory

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

Source from the content-addressed store, hash-verified

1235 self.assertIsNotNone(tar.getmember(longdir.removesuffix('/')))
1236
1237 def test_longname_file_not_directory(self):
1238 # Test reading a longname file and ensure it is not handled as a directory
1239 # Issue #141707
1240 buf = io.BytesIO()
1241 with tarfile.open(mode='w', fileobj=buf, format=self.format) as tar:
1242 ti = tarfile.TarInfo()
1243 ti.type = tarfile.AREGTYPE
1244 ti.name = ('a' * 99) + '/' + ('b' * 3)
1245 tar.addfile(ti)
1246
1247 expected = {t.name: t.type for t in tar.getmembers()}
1248
1249 buf.seek(0)
1250 with tarfile.open(mode='r', fileobj=buf) as tar:
1251 actual = {t.name: t.type for t in tar.getmembers()}
1252
1253 self.assertEqual(expected, actual)
1254
1255
1256class GNUReadTest(LongnameTest, ReadTest, unittest.TestCase):

Callers

nothing calls this directly

Calls 5

seekMethod · 0.95
addfileMethod · 0.80
getmembersMethod · 0.80
openMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected