From fc5f6a7f40fd0a2b936cab91b4305ba816f345b5 Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Sat, 20 Mar 2010 22:26:42 +0000 Subject: [PATCH] Cleanup test_tarfile, and use check_warnings. --- Lib/test/test_tarfile.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py index 353551d2a95..eb368cf01bf 100644 --- a/Lib/test/test_tarfile.py +++ b/Lib/test/test_tarfile.py @@ -69,7 +69,7 @@ class UstarReadTest(ReadTest): "fileobj.readlines() failed") self.assertTrue(len(lines2) == 114, "fileobj.readlines() failed") - self.assertTrue(lines2[83] == \ + self.assertTrue(lines2[83] == "I will gladly admit that Python is not the fastest running scripting language.\n", "fileobj.readlines() failed") @@ -707,11 +707,12 @@ class WriteTest(WriteTestBase): name = os.path.join(tempdir, name) open(name, "wb").close() - def exclude(name): - return os.path.isfile(name) + exclude = os.path.isfile tar = tarfile.open(tmpname, self.mode, encoding="iso8859-1") - tar.add(tempdir, arcname="empty_dir", exclude=exclude) + with test_support.check_warnings(("use the filter argument", + DeprecationWarning)): + tar.add(tempdir, arcname="empty_dir", exclude=exclude) tar.close() tar = tarfile.open(tmpname, "r") @@ -889,10 +890,12 @@ class GNUWriteTest(unittest.TestCase): tar = tarfile.open(tmpname) member = tar.next() - self.assertFalse(member is None, "unable to read longname member") - self.assertTrue(tarinfo.name == member.name and \ - tarinfo.linkname == member.linkname, \ - "unable to read longname member") + self.assertIsNotNone(member, + "unable to read longname member") + self.assertEqual(tarinfo.name, member.name, + "unable to read longname member") + self.assertEqual(tarinfo.linkname, member.linkname, + "unable to read longname member") def test_longname_1023(self): self._test(("longnam/" * 127) + "longnam") @@ -994,7 +997,7 @@ class PaxWriteTest(GNUWriteTest): u"test": u"äöü", u"äöü": u"test"} - tar = tarfile.open(tmpname, "w", format=tarfile.PAX_FORMAT, \ + tar = tarfile.open(tmpname, "w", format=tarfile.PAX_FORMAT, pax_headers=pax_headers) tar.addfile(tarfile.TarInfo("test")) tar.close()