[New-bugs-announce] [issue34031] Incorrect usage of unittest.TestCase in test_urllib2_localnet
Pablo Galindo Salgado
report at bugs.python.org
Tue Jul 3 08:35:20 EDT 2018
New submission from Pablo Galindo Salgado <pablogsal at gmail.com>:
In /Lib/test/test_urllib2_localnet.py there is an incorrect usage of unittest.TestCase (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
----------------------------------------------------------------------
----------
assignee: pablogsal
components: Tests
messages: 320975
nosy: pablogsal
priority: normal
severity: normal
status: open
title: Incorrect usage of unittest.TestCase in test_urllib2_localnet
type: behavior
versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34031>
_______________________________________
More information about the New-bugs-announce
mailing list