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

Method test_list

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 7

detachMethod · 0.95
convFunction · 0.85
assertInMethod · 0.80
assertRegexMethod · 0.80
assertNotInMethod · 0.80
listMethod · 0.45
getvalueMethod · 0.45

Tested by

no test coverage detected