]> granicus.if.org Git - python/commitdiff
Use "x in y" instead of y.find(x) != -1.
authorEzio Melotti <ezio.melotti@gmail.com>
Wed, 17 Mar 2010 14:22:34 +0000 (14:22 +0000)
committerEzio Melotti <ezio.melotti@gmail.com>
Wed, 17 Mar 2010 14:22:34 +0000 (14:22 +0000)
Lib/test/test_file.py
Lib/test/test_file2k.py
Lib/test/test_fileio.py
Lib/test/test_minidom.py

index 9b6b435a1ce342bd24b180b6b210f34b9ea479d4..c3c0defa51ea4cb64a01d142d0221711fcaf51ae 100644 (file)
@@ -172,7 +172,7 @@ class OtherFileTests(unittest.TestCase):
         except ValueError as msg:
             if msg.args[0] != 0:
                 s = str(msg)
-                if s.find(TESTFN) != -1 or s.find(bad_mode) == -1:
+                if TESTFN in s or bad_mode not in s:
                     self.fail("bad error message for invalid mode: %s" % s)
             # if msg.args[0] == 0, we're probably on Windows where there may be
             # no obvious way to discover why open() failed.
index f692533640e165f1a7a7c8c522c2e477d437028c..a7681a9a848bfa3e28a20194014b58285ebe7f01 100644 (file)
@@ -227,7 +227,7 @@ class OtherFileTests(unittest.TestCase):
         except ValueError, msg:
             if msg.args[0] != 0:
                 s = str(msg)
-                if s.find(TESTFN) != -1 or s.find(bad_mode) == -1:
+                if TESTFN in s or bad_mode not in s:
                     self.fail("bad error message for invalid mode: %s" % s)
             # if msg.args[0] == 0, we're probably on Windows where there may
             # be no obvious way to discover why open() failed.
index 505794117f5cfed8c5b4a15c0fb6f460fe229774..21d231fc012aab4175ea6d7cb7e22489cb8599e9 100644 (file)
@@ -320,7 +320,7 @@ class OtherFileTests(unittest.TestCase):
         except ValueError as msg:
             if msg.args[0] != 0:
                 s = str(msg)
-                if s.find(TESTFN) != -1 or s.find(bad_mode) == -1:
+                if TESTFN in s or bad_mode not in s:
                     self.fail("bad error message for invalid mode: %s" % s)
             # if msg.args[0] == 0, we're probably on Windows where there may be
             # no obvious way to discover why open() failed.
index fad7f36f76ec42735399171fa3cf7671e0bd9bfa..f160d09c6acf62fbb9d8a1b81a8e7787a26830ed 100644 (file)
@@ -433,7 +433,7 @@ class MinidomTest(unittest.TestCase):
         string1 = repr(el)
         string2 = str(el)
         self.confirm(string1 == string2)
-        self.confirm(string1.find("slash:abc") != -1)
+        self.confirm("slash:abc" in string1)
         dom.unlink()
 
     def testAttributeRepr(self):