Issue 34031: [EASY] Incorrect usage of unittest.TestCase in test_urllib2_localnet (original) (raw)
In /Lib/test/test_urllib2_localnet.py there is an incorrect usage of unittest.TestCase.fail (an extra comma makes it use two arguments instead of one):
class BasicAuthTests(unittest.TestCase): ...
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)
here self.fail takes two argument, but it only admits one. This produces this traceback if there are proxy issues when running the tests:
Traceback (most recent call last): File "/home7/pablogsal/Python-3.7.0/Lib/test/test_urllib2_localnet.py", line 307, in test_basic_auth_success self.assertTrue(urllib.request.urlopen(self.server_url)) File "/home/pablogsal/Python-3.7.0/Lib/urllib/request.py", line 222, in urlopen return opener.open(url, data, timeout) File "/home/pablogsal/Python-3.7.0/Lib/urllib/request.py", line 531, in open response = meth(req, response) File "/home/pablogsal/Python-3.7.0/Lib/urllib/request.py", line 641, in http_response 'http', request, response, code, msg, hdrs) File "/home/pablogsal/Python-3.7.0/Lib/urllib/request.py", line 569, in error return self._call_chain(*args) File "/home/pablogsal/Python-3.7.0/Lib/urllib/request.py", line 503, in _call_chain result = func(*args) File "/home/pablogsal/Python-3.7.0/Lib/urllib/request.py", line 649, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 403: Forbidden
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/pablogsal/Python-3.7.0/Lib/test/test_urllib2_localnet.py", line 309, in test_basic_auth_success self.fail("Basic auth failed for the url: %s", self.server_url) TypeError: fail() takes from 1 to 2 positional arguments but 3 were given