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

Method _test

Lib/test/test_tarfile.py:1933–1960  ·  view source on GitHub ↗
(self, name, link=None)

Source from the content-addressed store, hash-verified

1931 return count
1932
1933 def _test(self, name, link=None):
1934 tarinfo = tarfile.TarInfo(name)
1935 if link:
1936 tarinfo.linkname = link
1937 tarinfo.type = tarfile.LNKTYPE
1938
1939 tar = tarfile.open(tmpname, "w")
1940 try:
1941 tar.format = tarfile.GNU_FORMAT
1942 tar.addfile(tarinfo)
1943
1944 v1 = self._calc_size(name, link)
1945 v2 = tar.offset
1946 self.assertEqual(v1, v2, "GNU longname/longlink creation failed")
1947 finally:
1948 tar.close()
1949
1950 tar = tarfile.open(tmpname)
1951 try:
1952 member = tar.next()
1953 self.assertIsNotNone(member,
1954 "unable to read longname member")
1955 self.assertEqual(tarinfo.name, member.name,
1956 "unable to read longname member")
1957 self.assertEqual(tarinfo.linkname, member.linkname,
1958 "unable to read longname member")
1959 finally:
1960 tar.close()
1961
1962 def test_longname_1023(self):
1963 self._test(("longnam/" * 127) + "longnam")

Callers 9

test_longname_1023Method · 0.95
test_longname_1024Method · 0.95
test_longname_1025Method · 0.95
test_longlink_1023Method · 0.95
test_longlink_1024Method · 0.95
test_longlink_1025Method · 0.95

Calls 7

_calc_sizeMethod · 0.95
addfileMethod · 0.80
assertIsNotNoneMethod · 0.80
openMethod · 0.45
assertEqualMethod · 0.45
closeMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected