(self)
| 2239 | tar.close() |
| 2240 | |
| 2241 | def test_pax_global_header(self): |
| 2242 | pax_headers = { |
| 2243 | "foo": "bar", |
| 2244 | "uid": "0", |
| 2245 | "mtime": "1.23", |
| 2246 | "test": "\xe4\xf6\xfc", |
| 2247 | "\xe4\xf6\xfc": "test"} |
| 2248 | |
| 2249 | tar = tarfile.open(tmpname, "w", format=tarfile.PAX_FORMAT, |
| 2250 | pax_headers=pax_headers) |
| 2251 | try: |
| 2252 | tar.addfile(tarfile.TarInfo("test")) |
| 2253 | finally: |
| 2254 | tar.close() |
| 2255 | |
| 2256 | # Test if the global header was written correctly. |
| 2257 | tar = tarfile.open(tmpname, encoding="iso8859-1") |
| 2258 | try: |
| 2259 | self.assertEqual(tar.pax_headers, pax_headers) |
| 2260 | self.assertEqual(tar.getmembers()[0].pax_headers, pax_headers) |
| 2261 | # Test if all the fields are strings. |
| 2262 | for key, val in tar.pax_headers.items(): |
| 2263 | self.assertIsNot(type(key), bytes) |
| 2264 | self.assertIsNot(type(val), bytes) |
| 2265 | if key in tarfile.PAX_NUMBER_FIELDS: |
| 2266 | try: |
| 2267 | tarfile.PAX_NUMBER_FIELDS[key](val) |
| 2268 | except (TypeError, ValueError): |
| 2269 | self.fail("unable to convert pax header field") |
| 2270 | finally: |
| 2271 | tar.close() |
| 2272 | |
| 2273 | def test_pax_extended_header(self): |
| 2274 | # The fields from the pax header have priority over the |
nothing calls this directly
no test coverage detected