[Python-checkins] r79159 - python/trunk/Lib/test/test_tarfile.py

florent.xicluna python-checkins at python.org
Sat Mar 20 23:26:43 CET 2010


Author: florent.xicluna
Date: Sat Mar 20 23:26:42 2010
New Revision: 79159

Log:
Cleanup test_tarfile, and use check_warnings.


Modified:
   python/trunk/Lib/test/test_tarfile.py

Modified: python/trunk/Lib/test/test_tarfile.py
==============================================================================
--- python/trunk/Lib/test/test_tarfile.py	(original)
+++ python/trunk/Lib/test/test_tarfile.py	Sat Mar 20 23:26:42 2010
@@ -69,7 +69,7 @@
                 "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 @@
                 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 @@
 
         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 @@
                 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()


More information about the Python-checkins mailing list