[Python-checkins] bpo-34031: fix incorrect usage of self.fail in two tests (GH-8091)

Miss Islington (bot) webhook-mailer at python.org
Tue Jul 10 06:13:10 EDT 2018


https://github.com/python/cpython/commit/cb14eb7eedf36cd21aaf41c4d3eb1e6521fa7b11
commit: cb14eb7eedf36cd21aaf41c4d3eb1e6521fa7b11
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2018-07-10T03:13:06-07:00
summary:

bpo-34031: fix incorrect usage of self.fail in two tests (GH-8091)


Contributed by Bradley Laney.
(cherry picked from commit 6b490b5db40fc29588e8e6cc23bb89c4fed74ad5)

Co-authored-by: Bradley Laney <bradley.laney at gmail.com>

files:
M Lib/test/test_file.py
M Lib/test/test_urllib2_localnet.py

diff --git a/Lib/test/test_file.py b/Lib/test/test_file.py
index 9890b8c586f3..f58d1dae6045 100644
--- a/Lib/test/test_file.py
+++ b/Lib/test/test_file.py
@@ -241,8 +241,7 @@ def testIteration(self):
         # 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()
diff --git a/Lib/test/test_urllib2_localnet.py b/Lib/test/test_urllib2_localnet.py
index 9d9ec8726d8a..ef0091c49300 100644
--- a/Lib/test/test_urllib2_localnet.py
+++ b/Lib/test/test_urllib2_localnet.py
@@ -308,7 +308,7 @@ def test_basic_auth_success(self):
         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()



More information about the Python-checkins mailing list