Page MenuHomePhabricator

failing doctest: pywikibot.data.memento.MementoClient
Closed, ResolvedPublicBUG REPORT

Description

https://integration.wikimedia.org/ci/job/pywikibot-core-tox-doctest-docker/5430/console

19:09:07 doctest run-test: commands[2] | nosetests --with-doctest pywikibot '--ignore-files=(eventstreams|gui|mysql|xmlreader)\.py'
19:09:07 [165] /src$ /src/.tox/doctest/bin/nosetests --with-doctest pywikibot '--ignore-files=(eventstreams|gui|mysql|xmlreader)\.py'
19:09:07 ..WARNING: /src/pywikibot/data/api/_requests.py:1: RuntimeWarning: Request() invoked without a site; setting to wikipedia:test
19:09:07   """Objects representing API requests."""
19:09:07 
19:09:33 .F....................
19:09:33 ======================================================================
19:09:33 FAIL: Doctest: pywikibot.data.memento.MementoClient
19:09:33 ----------------------------------------------------------------------
19:09:33 Traceback (most recent call last):
19:09:33   File "/usr/lib/python3.7/doctest.py", line 2196, in runTest
19:09:33     raise self.failureException(self.format_failure(new.getvalue()))
19:09:33 AssertionError: Failed doctest test for pywikibot.data.memento.MementoClient
19:09:33   File "/src/pywikibot/data/memento.py", line 35, in MementoClient
19:09:33 
19:09:33 ----------------------------------------------------------------------
19:09:33 File "/src/pywikibot/data/memento.py", line 48, in pywikibot.data.memento.MementoClient
19:09:33 Failed example:
19:09:33     mc = mc.get_memento_info("http://www.bbc.com/", dt)
19:09:33 Exception raised:
19:09:33     Traceback (most recent call last):
19:09:33       File "/src/.tox/doctest/lib/python3.7/site-packages/urllib3/connectionpool.py", line 449, in _make_request
19:09:33         six.raise_from(e, None)
19:09:33       File "<string>", line 3, in raise_from
19:09:33       File "/src/.tox/doctest/lib/python3.7/site-packages/urllib3/connectionpool.py", line 444, in _make_request
19:09:33         httplib_response = conn.getresponse()
19:09:33       File "/usr/lib/python3.7/http/client.py", line 1352, in getresponse
19:09:33         response.begin()
19:09:33       File "/usr/lib/python3.7/http/client.py", line 310, in begin
19:09:33         version, status, reason = self._read_status()
19:09:33       File "/usr/lib/python3.7/http/client.py", line 271, in _read_status
19:09:33         line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
19:09:33       File "/usr/lib/python3.7/socket.py", line 589, in readinto
19:09:33         return self._sock.recv_into(b)
19:09:33     socket.timeout: timed out
19:09:33 
19:09:33     During handling of the above exception, another exception occurred:
19:09:33 
19:09:33     Traceback (most recent call last):
19:09:33       File "/src/.tox/doctest/lib/python3.7/site-packages/requests/adapters.py", line 499, in send
19:09:33         timeout=timeout,
19:09:33       File "/src/.tox/doctest/lib/python3.7/site-packages/urllib3/connectionpool.py", line 786, in urlopen
19:09:33         method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
19:09:33       File "/src/.tox/doctest/lib/python3.7/site-packages/urllib3/util/retry.py", line 550, in increment
19:09:33         raise six.reraise(type(error), error, _stacktrace)
19:09:33       File "/src/.tox/doctest/lib/python3.7/site-packages/urllib3/packages/six.py", line 770, in reraise
19:09:33         raise value
19:09:33       File "/src/.tox/doctest/lib/python3.7/site-packages/urllib3/connectionpool.py", line 710, in urlopen
19:09:33         chunked=chunked,
19:09:33       File "/src/.tox/doctest/lib/python3.7/site-packages/urllib3/connectionpool.py", line 451, in _make_request
19:09:33         self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
19:09:33       File "/src/.tox/doctest/lib/python3.7/site-packages/urllib3/connectionpool.py", line 341, in _raise_timeout
19:09:33         self, url, "Read timed out. (read timeout=%s)" % timeout_value
19:09:33     urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='timetravel.mementoweb.org', port=80): Read timed out. (read timeout=9)
19:09:33 
19:09:33     During handling of the above exception, another exception occurred:
19:09:33 
19:09:33     Traceback (most recent call last):
19:09:33       File "/usr/lib/python3.7/doctest.py", line 1329, in __run
19:09:33         compileflags, 1), test.globs)
19:09:33       File "<doctest pywikibot.data.memento.MementoClient[2]>", line 1, in <module>
19:09:33         mc = mc.get_memento_info("http://www.bbc.com/", dt)
19:09:33       File "/src/pywikibot/data/memento.py", line 140, in get_memento_info
19:09:33         timeout=timeout
19:09:33       File "/src/pywikibot/data/memento.py", line 284, in request_head
19:09:33         timeout=timeout or 9)
19:09:33       File "/src/.tox/doctest/lib/python3.7/site-packages/requests/sessions.py", line 622, in head
19:09:33         return self.request("HEAD", url, **kwargs)
19:09:33       File "/src/.tox/doctest/lib/python3.7/site-packages/requests/sessions.py", line 587, in request
19:09:33         resp = self.send(prep, **send_kwargs)
19:09:33       File "/src/.tox/doctest/lib/python3.7/site-packages/requests/sessions.py", line 701, in send
19:09:33         r = adapter.send(request, **kwargs)
19:09:33       File "/src/.tox/doctest/lib/python3.7/site-packages/requests/adapters.py", line 578, in send
19:09:33         raise ReadTimeout(e, request=request)
19:09:33     requests.exceptions.ReadTimeout: HTTPConnectionPool(host='timetravel.mementoweb.org', port=80): Read timed out. (read timeout=9)
19:09:33 ----------------------------------------------------------------------
19:09:33 File "/src/pywikibot/data/memento.py", line 49, in pywikibot.data.memento.MementoClient
19:09:33 Failed example:
19:09:33     print(mc['original_uri'])
19:09:33 Exception raised:
19:09:33     Traceback (most recent call last):
19:09:33       File "/usr/lib/python3.7/doctest.py", line 1329, in __run
19:09:33         compileflags, 1), test.globs)
19:09:33       File "<doctest pywikibot.data.memento.MementoClient[3]>", line 1, in <module>
19:09:33         print(mc['original_uri'])
19:09:33     TypeError: 'MementoClient' object is not subscriptable
19:09:33 ----------------------------------------------------------------------
19:09:33 File "/src/pywikibot/data/memento.py", line 51, in pywikibot.data.memento.MementoClient
19:09:33 Failed example:
19:09:33     print(mc['timegate_uri'])
19:09:33 Exception raised:
19:09:33     Traceback (most recent call last):
19:09:33       File "/usr/lib/python3.7/doctest.py", line 1329, in __run
19:09:33         compileflags, 1), test.globs)
19:09:33       File "<doctest pywikibot.data.memento.MementoClient[4]>", line 1, in <module>
19:09:33         print(mc['timegate_uri'])
19:09:33     TypeError: 'MementoClient' object is not subscriptable
19:09:33 ----------------------------------------------------------------------
19:09:33 File "/src/pywikibot/data/memento.py", line 53, in pywikibot.data.memento.MementoClient
19:09:33 Failed example:
19:09:33     print(sorted(mc['mementos']))
19:09:33 Exception raised:
19:09:33     Traceback (most recent call last):
19:09:33       File "/usr/lib/python3.7/doctest.py", line 1329, in __run
19:09:33         compileflags, 1), test.globs)
19:09:33       File "<doctest pywikibot.data.memento.MementoClient[5]>", line 1, in <module>
19:09:33         print(sorted(mc['mementos']))
19:09:33     TypeError: 'MementoClient' object is not subscriptable
19:09:33 ----------------------------------------------------------------------
19:09:33 File "/src/pywikibot/data/memento.py", line 55, in pywikibot.data.memento.MementoClient
19:09:33 Failed example:
19:09:33     del mc['mementos']['last']
19:09:33 Exception raised:
19:09:33     Traceback (most recent call last):
19:09:33       File "/usr/lib/python3.7/doctest.py", line 1329, in __run
19:09:33         compileflags, 1), test.globs)
19:09:33       File "<doctest pywikibot.data.memento.MementoClient[6]>", line 1, in <module>
19:09:33         del mc['mementos']['last']
19:09:33     TypeError: 'MementoClient' object is not subscriptable
19:09:33 ----------------------------------------------------------------------
19:09:33 File "/src/pywikibot/data/memento.py", line 57, in pywikibot.data.memento.MementoClient
19:09:33 Failed example:
19:09:33     pprint(mc['mementos'])
19:09:33 Exception raised:
19:09:33     Traceback (most recent call last):
19:09:33       File "/usr/lib/python3.7/doctest.py", line 1329, in __run
19:09:33         compileflags, 1), test.globs)
19:09:33       File "<doctest pywikibot.data.memento.MementoClient[8]>", line 1, in <module>
19:09:33         pprint(mc['mementos'])
19:09:33     TypeError: 'MementoClient' object is not subscriptable
19:09:33 
19:09:33 -------------------- >> begin captured logging << --------------------
19:09:33 urllib3.connectionpool: DEBUG: Starting new HTTP connection (1): www.bbc.com:80
19:09:33 urllib3.connectionpool: DEBUG: http://www.bbc.com:80 "HEAD / HTTP/1.1" 301 0
19:09:33 urllib3.connectionpool: DEBUG: Starting new HTTPS connection (1): www.bbc.com:443
19:09:33 urllib3.connectionpool: DEBUG: https://www.bbc.com:443 "HEAD / HTTP/1.1" 200 0
19:09:33 urllib3.connectionpool: DEBUG: http://www.bbc.com:80 "HEAD / HTTP/1.1" 301 0
19:09:33 root: DEBUG: Been redirected from URI-R: http://www.bbc.com/
19:09:33 root: DEBUG: Following to new URI of https://www.bbc.com/
19:09:33 urllib3.connectionpool: DEBUG: https://www.bbc.com:443 "HEAD / HTTP/1.1" 200 0
19:09:33 root: DEBUG: No URI-G found for URI-R: https://www.bbc.com/
19:09:33 urllib3.connectionpool: DEBUG: Starting new HTTP connection (1): timetravel.mementoweb.org:80
19:09:33 --------------------- >> end captured logging << ---------------------
19:09:33 
19:09:33 ----------------------------------------------------------------------
19:09:33 Ran 24 tests in 26.136s
19:09:33 
19:09:33 FAILED (failures=1)
19:09:34 ERROR: InvocationError for command /src/.tox/doctest/bin/nosetests --with-doctest pywikibot '--ignore-files=(eventstreams|gui|mysql|xmlreader)\.py' (exited with code 1)
19:09:34 ___________________________________ summary ____________________________________
19:09:34 ERROR:   doctest: commands failed

Event Timeline

Xqt triaged this task as Medium priority.Jul 1 2022, 4:25 PM
Xqt added a project: Pywikibot-tests.
Xqt subscribed.

The test passes usually but in this case there was a socket timeout. Is there a way to skip this test in such case?

Xqt lowered the priority of this task from Medium to Lowest.Oct 14 2022, 9:02 AM

doctests were disabled for memento

Xqt claimed this task.

Memento client results are not deterministic and calling the server often fails due to timeout. Therefore doctests should not be restored.