MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_pax_global_header

Method test_pax_global_header

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

Source from the content-addressed store, hash-verified

2222 tar.close()
2223
2224 def test_pax_global_header(self):
2225 pax_headers = {
2226 "foo": "bar",
2227 "uid": "0",
2228 "mtime": "1.23",
2229 "test": "\xe4\xf6\xfc",
2230 "\xe4\xf6\xfc": "test"}
2231
2232 tar = tarfile.open(tmpname, "w", format=tarfile.PAX_FORMAT,
2233 pax_headers=pax_headers)
2234 try:
2235 tar.addfile(tarfile.TarInfo("test"))
2236 finally:
2237 tar.close()
2238
2239 # Test if the global header was written correctly.
2240 tar = tarfile.open(tmpname, encoding="iso8859-1")
2241 try:
2242 self.assertEqual(tar.pax_headers, pax_headers)
2243 self.assertEqual(tar.getmembers()[0].pax_headers, pax_headers)
2244 # Test if all the fields are strings.
2245 for key, val in tar.pax_headers.items():
2246 self.assertIsNot(type(key), bytes)
2247 self.assertIsNot(type(val), bytes)
2248 if key in tarfile.PAX_NUMBER_FIELDS:
2249 try:
2250 tarfile.PAX_NUMBER_FIELDS[key](val)
2251 except (TypeError, ValueError):
2252 self.fail("unable to convert pax header field")
2253 finally:
2254 tar.close()
2255
2256 def test_pax_extended_header(self):
2257 # The fields from the pax header have priority over the

Callers

nothing calls this directly

Calls 8

addfileMethod · 0.80
getmembersMethod · 0.80
assertIsNotMethod · 0.80
openMethod · 0.45
closeMethod · 0.45
assertEqualMethod · 0.45
itemsMethod · 0.45
failMethod · 0.45

Tested by

no test coverage detected