twisted / pydoctor

This is pydoctor, an API documentation generator that works by static analysis.
https://pydoctor.readthedocs.io
Other
179 stars 48 forks source link

Fix incompatibility with cachecontrol v0.13.0 (in tests fixture) #715

Closed tristanlatr closed 1 year ago

tristanlatr commented 1 year ago

Tests are failing with the following error:

=================================== FAILURES ===================================
_______________________ TestIntersphinxCache.test_cache ________________________

self = <pydoctor.test.test_sphinx.TestIntersphinxCache object at 0x7f02a6ae4fd0>
tmp_path = PosixPath('/tmp/pytest-of-runner/pytest-0/test_cache0')
send_returns = <function TestIntersphinxCache.send_returns.<locals>.send_returns at 0x7f02a35213b0>

    def test_cache(self, tmp_path: Path, send_returns: Callable[[HTTPResponse], None]) -> None:
        """
        L{IntersphinxCache.get} caches responses to the file system.
        """
        url = "https://cache.example/objects.inv"
        content = b'content'

        send_returns(
            HTTPResponse(
                body=ClosingBytesIO(content),
                headers={
                    'date': 'Sun, 06 Nov 1994 08:49:37 GMT',
                },
                status=200,
                preload_content=False,
                decode_content=False,
            ),
        )

        loadsCache = sphinx.IntersphinxCache.fromParameters(
            sessionFactory=requests.Session,
            cachePath=str(tmp_path),
            maxAgeDictionary={"weeks": 1}
        )

>       assert loadsCache.get(url) == content
E       AssertionError: assert None == b'content'
E        +  where None = <bound method IntersphinxCache.get of IntersphinxCache(_session=<requests.sessions.Session object at 0x7f02a6be2d50>, _logger=<Logger pydoctor.sphinx (WARNING)>)>('https://cache.example/objects.inv')
E        +    where <bound method IntersphinxCache.get of IntersphinxCache(_session=<requests.sessions.Session object at 0x7f02a6be2d50>, _logger=<Logger pydoctor.sphinx (WARNING)>)> = IntersphinxCache(_session=<requests.sessions.Session object at 0x7f02a6be2d50>, _logger=<Logger pydoctor.sphinx (WARNING)>).get

pydoctor/test/test_sphinx.py:638: AssertionError
------------------------------ Captured log call -------------------------------
ERROR    pydoctor.sphinx:sphinx.py:401 Could not retrieve intersphinx object.inv from https://cache.example/objects.inv
Traceback (most recent call last):
  File "/home/runner/work/pydoctor/pydoctor/pydoctor/sphinx.py", line 397, in get
    return self._session.get(url).content
  File "/home/runner/work/pydoctor/pydoctor/.tox/test/lib/python3.7/site-packages/requests/sessions.py", line 602, in get
    return self.request("GET", url, **kwargs)
  File "/home/runner/work/pydoctor/pydoctor/.tox/test/lib/python3.7/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/runner/work/pydoctor/pydoctor/.tox/test/lib/python3.7/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
  File "/home/runner/work/pydoctor/pydoctor/.tox/test/lib/python3.7/site-packages/cachecontrol/adapter.py", line 78, in send
    request, stream, timeout, verify, cert, proxies
TypeError: send() takes 2 positional arguments but 7 were given
=========================== short test summary info ============================
FAILED pydoctor/test/test_sphinx.py::TestIntersphinxCache::test_cache - AssertionError: assert None == b'content'
 +  where None = <bound method IntersphinxCache.get of IntersphinxCache(_session=<requests.sessions.Session object at 0x7f02a6be2d50>, _logger=<Logger pydoctor.sphinx (WARNING)>)>('https://cache.example/objects.inv')
 +    where <bound method IntersphinxCache.get of IntersphinxCache(_session=<requests.sessions.Session object at 0x7f02a6be2d50>, _logger=<Logger pydoctor.sphinx (WARNING)>)> = IntersphinxCache(_session=<requests.sessions.Session object at 0x7f02a6be2d50>, _logger=<Logger pydoctor.sphinx (WARNING)>).get
============ 1 failed, 1163 passed, 54 skipped, 2 xfailed in 35.56s ============

Here is the cachecontrol changelog: https://github.com/psf/cachecontrol/compare/v0.12.12...v0.13.0