(self)
| 293 | self.tar = tarfile.open(self.tarname, mode=self.mode) |
| 294 | |
| 295 | def test_list(self): |
| 296 | tio = io.TextIOWrapper(io.BytesIO(), 'ascii', newline='\n') |
| 297 | with support.swap_attr(sys, 'stdout', tio): |
| 298 | self.tar.list(verbose=False) |
| 299 | out = tio.detach().getvalue() |
| 300 | self.assertIn(b'ustar/conttype', out) |
| 301 | self.assertIn(b'ustar/regtype', out) |
| 302 | self.assertIn(b'ustar/lnktype', out) |
| 303 | self.assertIn(b'ustar' + (b'/12345' * 40) + b'67/longname', out) |
| 304 | self.assertIn(b'./ustar/linktest2/symtype', out) |
| 305 | self.assertIn(b'./ustar/linktest2/lnktype', out) |
| 306 | # Make sure it puts trailing slash for directory |
| 307 | self.assertIn(b'ustar/dirtype/', out) |
| 308 | self.assertIn(b'ustar/dirtype-with-size/', out) |
| 309 | # Make sure it is able to print unencodable characters |
| 310 | def conv(b): |
| 311 | s = b.decode(self.tar.encoding, 'surrogateescape') |
| 312 | return s.encode('ascii', 'backslashreplace') |
| 313 | self.assertIn(conv(b'ustar/umlauts-\xc4\xd6\xdc\xe4\xf6\xfc\xdf'), out) |
| 314 | self.assertIn(conv(b'misc/regtype-hpux-signed-chksum-' |
| 315 | b'\xc4\xd6\xdc\xe4\xf6\xfc\xdf'), out) |
| 316 | self.assertIn(conv(b'misc/regtype-old-v7-signed-chksum-' |
| 317 | b'\xc4\xd6\xdc\xe4\xf6\xfc\xdf'), out) |
| 318 | self.assertIn(conv(b'pax/bad-pax-\xe4\xf6\xfc'), out) |
| 319 | self.assertIn(conv(b'pax/hdrcharset-\xe4\xf6\xfc'), out) |
| 320 | # Make sure it prints files separated by one newline without any |
| 321 | # 'ls -l'-like accessories if verbose flag is not being used |
| 322 | # ... |
| 323 | # ustar/conttype |
| 324 | # ustar/regtype |
| 325 | # ... |
| 326 | self.assertRegex(out, br'ustar/conttype ?\r?\n' |
| 327 | br'ustar/regtype ?\r?\n') |
| 328 | # Make sure it does not print the source of link without verbose flag |
| 329 | self.assertNotIn(b'link to', out) |
| 330 | self.assertNotIn(b'->', out) |
| 331 | |
| 332 | def test_list_verbose(self): |
| 333 | tio = io.TextIOWrapper(io.BytesIO(), 'ascii', newline='\n') |
nothing calls this directly
no test coverage detected