From a7eb74627826e389dd78bd5a7a3b0878f4e3dde6 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Thu, 21 Aug 2014 10:01:16 +0300 Subject: Issue #21549: Added the "members" parameter to TarFile.list(). --- Lib/test/test_tarfile.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'Lib/test/test_tarfile.py') diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py index e527e403fa..810b76be53 100644 --- a/Lib/test/test_tarfile.py +++ b/Lib/test/test_tarfile.py @@ -285,6 +285,18 @@ class ListTest(ReadTest, unittest.TestCase): self.assertIn(b'pax' + (b'/123' * 125) + b'/longlink link to pax' + (b'/123' * 125) + b'/longname', out) + def test_list_members(self): + tio = io.TextIOWrapper(io.BytesIO(), 'ascii', newline='\n') + def members(tar): + for tarinfo in tar.getmembers(): + if 'reg' in tarinfo.name: + yield tarinfo + with support.swap_attr(sys, 'stdout', tio): + self.tar.list(verbose=False, members=members(self.tar)) + out = tio.detach().getvalue() + self.assertIn(b'ustar/regtype', out) + self.assertNotIn(b'ustar/conttype', out) + class GzipListTest(GzipTest, ListTest): pass -- cgit v1.2.1