New submission from Pablo Galindo Salgado <[email protected]>:
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 <[email protected]>
<https://bugs.python.org/issue34031>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com