Xqt created this task.
Xqt added projects: Pywikibot, Pywikibot-tests.
Restricted Application added subscribers: pywikibot-bugs-list, Aklapper.
TASK DESCRIPTION
**Steps to replicate the issue**:
`pwb http_tests -v TestHttpStatus.test_server_not_found`
**What happens?**:
=================================== FAILURES
===================================
18:06:56 _____________________ TestHttpStatus.test_server_not_found
_____________________
18:06:56
18:06:56 self = <tests.http_tests.TestHttpStatus
testMethod=test_server_not_found>
18:06:56
18:06:56 def test_server_not_found(self):
18:06:56 """Test server not found exception."""
18:06:56 with self.assertRaisesRegex(
18:06:56 ConnectionError,
18:06:56 'Max retries exceeded with url: /w/api.php'):
18:06:56 > http.fetch('http://ru-sib.wikipedia.org/w/api.php',
18:06:56 default_error_handling=True)
18:06:56
18:06:56 tests/http_tests.py:149:
18:06:56 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _
18:06:56 pywikibot/comms/http.py:453: in fetch
18:06:56 callback(response)
18:06:56 pywikibot/comms/http.py:338: in error_handling_callback
18:06:56 raise response from None
18:06:56 pywikibot/comms/http.py:444: in fetch
18:06:56 response = session.request(method, uri,
18:06:56
.tox/deeptest-py39/lib/python3.9/site-packages/requests/sessions.py:587: in
request
18:06:56 resp = self.send(prep, **send_kwargs)
18:06:56
.tox/deeptest-py39/lib/python3.9/site-packages/requests/sessions.py:701: in send
18:06:56 r = adapter.send(request, **kwargs)
18:06:56 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _
18:06:56
18:06:56 def send(
18:06:56 self, request, stream=False, timeout=None, verify=True,
cert=None, proxies=None
18:06:56 ):
18:06:56 """Sends PreparedRequest object. Returns Response object.
18:06:56
18:06:56 :param request: The :class:`PreparedRequest
<PreparedRequest>` being sent.
18:06:56 :param stream: (optional) Whether to stream the request
content.
18:06:56 :param timeout: (optional) How long to wait for the server
to send
18:06:56 data before giving up, as a float, or a :ref:`(connect
timeout,
18:06:56 read timeout) <timeouts>` tuple.
18:06:56 :type timeout: float or tuple or urllib3 Timeout object
18:06:56 :param verify: (optional) Either a boolean, in which case
it controls whether
18:06:56 we verify the server's TLS certificate, or a string,
in which case it
18:06:56 must be a path to a CA bundle to use
18:06:56 :param cert: (optional) Any user-provided SSL certificate
to be trusted.
18:06:56 :param proxies: (optional) The proxies dictionary to apply
to the request.
18:06:56 :rtype: requests.Response
18:06:56 """
18:06:56
18:06:56 try:
18:06:56 conn = self.get_connection(request.url, proxies)
18:06:56 except LocationValueError as e:
18:06:56 raise InvalidURL(e, request=request)
18:06:56
18:06:56 self.cert_verify(conn, request.url, verify, cert)
18:06:56 url = self.request_url(request, proxies)
18:06:56 self.add_headers(
18:06:56 request,
18:06:56 stream=stream,
18:06:56 timeout=timeout,
18:06:56 verify=verify,
18:06:56 cert=cert,
18:06:56 proxies=proxies,
18:06:56 )
18:06:56
18:06:56 chunked = not (request.body is None or "Content-Length" in
request.headers)
18:06:56
18:06:56 if isinstance(timeout, tuple):
18:06:56 try:
18:06:56 connect, read = timeout
18:06:56 timeout = TimeoutSauce(connect=connect, read=read)
18:06:56 except ValueError:
18:06:56 raise ValueError(
18:06:56 f"Invalid timeout {timeout}. Pass a (connect,
read) timeout tuple, "
18:06:56 f"or a single float to set both timeouts to
the same value."
18:06:56 )
18:06:56 elif isinstance(timeout, TimeoutSauce):
18:06:56 pass
18:06:56 else:
18:06:56 timeout = TimeoutSauce(connect=timeout, read=timeout)
18:06:56
18:06:56 try:
18:06:56 resp = conn.urlopen(
18:06:56 method=request.method,
18:06:56 url=url,
18:06:56 body=request.body,
18:06:56 headers=request.headers,
18:06:56 redirect=False,
18:06:56 assert_same_host=False,
18:06:56 preload_content=False,
18:06:56 decode_content=False,
18:06:56 retries=self.max_retries,
18:06:56 timeout=timeout,
18:06:56 chunked=chunked,
18:06:56 )
18:06:56
18:06:56 except (ProtocolError, OSError) as err:
18:06:56 raise ConnectionError(err, request=request)
18:06:56
18:06:56 except MaxRetryError as e:
18:06:56 if isinstance(e.reason, ConnectTimeoutError):
18:06:56 # TODO: Remove this in 3.0.0: see #2811
18:06:56 if not isinstance(e.reason, NewConnectionError):
18:06:56 raise ConnectTimeout(e, request=request)
18:06:56
18:06:56 if isinstance(e.reason, ResponseError):
18:06:56 raise RetryError(e, request=request)
18:06:56
18:06:56 if isinstance(e.reason, _ProxyError):
18:06:56 raise ProxyError(e, request=request)
18:06:56
18:06:56 if isinstance(e.reason, _SSLError):
18:06:56 # This branch is for urllib3 v1.22 and later.
18:06:56 raise SSLError(e, request=request)
18:06:56
18:06:56 > raise ConnectionError(e, request=request)
18:06:56 E requests.exceptions.ConnectionError:
HTTPConnectionPool(host='ru-sib.wikipedia.org', port=80): Max retries exceeded
with url: /w/api.php (Caused by
NameResolutionError("<urllib3.connection.HTTPConnection object at
0x7fcdf204e910>: Failed to resolve 'ru-sib.wikipedia.org' ([Errno -2] Name or
service not known)"))
18:06:56
18:06:56
.tox/deeptest-py39/lib/python3.9/site-packages/requests/adapters.py:519:
ConnectionError
TASK DETAIL
https://phabricator.wikimedia.org/T336280
EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: Xqt
Cc: Aklapper, pywikibot-bugs-list, Xqt, PotsdamLamb, Jyoo1011, JohnsonLee01,
SHEKH, Dijkstra, Khutuck, Zkhalido, Viztor, Wenyi, Tbscho, MayS, Framawiki,
Mdupont, JJMC89, Dvorapa, Altostratus, binbot, Avicennasis, mys_721tx, jayvdb,
Masti, Alchimista
_______________________________________________
pywikibot-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]