MCPcopy Index your code
hub / github.com/python/cpython / test_list_verbose

Method test_list_verbose

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

Source from the content-addressed store, hash-verified

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