From: Ezio Melotti Date: Wed, 17 Mar 2010 14:22:34 +0000 (+0000) Subject: Use "x in y" instead of y.find(x) != -1. X-Git-Tag: v2.7b1~338 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=187f93d986a571b0a7d797a3b114d5d877d261e1;p=python Use "x in y" instead of y.find(x) != -1. --- diff --git a/Lib/test/test_file.py b/Lib/test/test_file.py index 9b6b435a1c..c3c0defa51 100644 --- a/Lib/test/test_file.py +++ b/Lib/test/test_file.py @@ -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. diff --git a/Lib/test/test_file2k.py b/Lib/test/test_file2k.py index f692533640..a7681a9a84 100644 --- a/Lib/test/test_file2k.py +++ b/Lib/test/test_file2k.py @@ -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. diff --git a/Lib/test/test_fileio.py b/Lib/test/test_fileio.py index 505794117f..21d231fc01 100644 --- a/Lib/test/test_fileio.py +++ b/Lib/test/test_fileio.py @@ -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. diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py index fad7f36f76..f160d09c6a 100644 --- a/Lib/test/test_minidom.py +++ b/Lib/test/test_minidom.py @@ -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):