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

Method test_list_verbose

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

Source from the content-addressed store, hash-verified

332 self.assertNotIn(b'->', out)
333
334 def test_list_verbose(self):
335 tio = io.TextIOWrapper(io.BytesIO(), 'ascii', newline='\n')
336 with support.swap_attr(sys, 'stdout', tio):
337 self.tar.list(verbose=True)
338 out = tio.detach().getvalue()
339 # Make sure it prints files separated by one newline with 'ls -l'-like
340 # accessories if verbose flag is being used
341 # ...
342 # ?rw-r--r-- tarfile/tarfile 7011 2003-01-06 07:19:43 ustar/conttype
343 # -rw-r--r-- tarfile/tarfile 7011 2003-01-06 07:19:43 ustar/regtype
344 # drwxr-xr-x tarfile/tarfile 0 2003-01-05 15:19:43 ustar/dirtype/
345 # ...
346 #
347 # Array of values to modify the regex below:
348 # ((file_type, file_permissions, file_length), ...)
349 type_perm_lengths = (
350 (br'\?', b'rw-r--r--', b'7011'), (b'-', b'rw-r--r--', b'7011'),
351 (b'd', b'rwxr-xr-x', b'0'), (b'd', b'rwxr-xr-x', b'255'),
352 (br'\?', b'rw-r--r--', b'0'), (b'l', b'rwxrwxrwx', b'0'),
353 (b'b', b'rw-rw----', b'3,0'), (b'c', b'rw-rw-rw-', b'1,3'),
354 (b'p', b'rw-r--r--', b'0'))
355 self.assertRegex(out, b''.join(
356 [(tp + (br'%s tarfile/tarfile\s+%s ' % (perm, ln) +
357 br'\d{4}-\d\d-\d\d\s+\d\d:\d\d:\d\d '
358 br'ustar/\w+type[/>\sa-z-]*\n')) for tp, perm, ln
359 in type_perm_lengths]))
360 # Make sure it prints the source of link with verbose flag
361 self.assertIn(b'ustar/symtype -> regtype', out)
362 self.assertIn(b'./ustar/linktest2/symtype -> ../linktest1/regtype', out)
363 self.assertIn(b'./ustar/linktest2/lnktype link to '
364 b'./ustar/linktest1/regtype', out)
365 self.assertIn(b'gnu' + (b'/123' * 125) + b'/longlink link to gnu' +
366 (b'/123' * 125) + b'/longname', out)
367 self.assertIn(b'pax' + (b'/123' * 125) + b'/longlink link to pax' +
368 (b'/123' * 125) + b'/longname', out)
369
370 def test_list_members(self):
371 tio = io.TextIOWrapper(io.BytesIO(), 'ascii', newline='\n')

Callers

nothing calls this directly

Calls 6

detachMethod · 0.95
assertRegexMethod · 0.80
assertInMethod · 0.80
listMethod · 0.45
getvalueMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected