]> granicus.if.org Git - python/commitdiff
bpo-34031: fix incorrect usage of self.fail in two tests (GH-8091)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 10 Jul 2018 10:13:06 +0000 (03:13 -0700)
committerGitHub <noreply@github.com>
Tue, 10 Jul 2018 10:13:06 +0000 (03:13 -0700)
Contributed by Bradley Laney.
(cherry picked from commit 6b490b5db40fc29588e8e6cc23bb89c4fed74ad5)

Co-authored-by: Bradley Laney <bradley.laney@gmail.com>
Lib/test/test_file.py
Lib/test/test_urllib2_localnet.py

index 9890b8c586f380f3bfbdd76328b4c06e2c9fc467..f58d1dae6045f49ff17ae8a852ed6ab8371f92b0 100644 (file)
@@ -241,8 +241,7 @@ class OtherFileTests:
         # Test for appropriate errors mixing read* and iteration
         for methodname, args in methods:
             f = self.open(TESTFN, 'rb')
-            if next(f) != filler:
-                self.fail, "Broken testfile"
+            self.assertEqual(next(f), filler)
             meth = getattr(f, methodname)
             meth(*args)  # This simply shouldn't fail
             f.close()
index 9d9ec8726d8a6b15f1d49e2f80cb04419abc4d64..ef0091c49300f55ecc7de6eb838c2d1558419bbb 100644 (file)
@@ -308,7 +308,7 @@ class BasicAuthTests(unittest.TestCase):
         try:
             self.assertTrue(urllib.request.urlopen(self.server_url))
         except urllib.error.HTTPError:
-            self.fail("Basic auth failed for the url: %s", self.server_url)
+            self.fail("Basic auth failed for the url: %s" % self.server_url)
 
     def test_basic_auth_httperror(self):
         ah = urllib.request.HTTPBasicAuthHandler()