Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

TODO: undo pin of 'aiohttp' once 'aioresponses' releases a fix #632

Closed

Description

@davidwtbuxton

Environment details

  • OS: $ sw_vers
    ProductName: Mac OS X
    ProductVersion: 10.14.6
    BuildVersion: 18G6020

  • Python version: 3.6, 3.7, 3.8

  • pip version: pip 20.2.4

  • google-auth version: 5906c85

Steps to reproduce

  1. nox -s unit

There are 9 tests that fail, all with the same error:

TypeError: __init__() missing 1 required positional argument: 'limit'

====================================================== short test summary info =======================================================
FAILED tests_async/transport/test_aiohttp_requests.py::TestCombinedResponse::test_content_compressed - TypeError: __init__() missin...
FAILED tests_async/transport/test_aiohttp_requests.py::TestResponse::test_headers_prop - TypeError: __init__() missing 1 required p...
FAILED tests_async/transport/test_aiohttp_requests.py::TestResponse::test_status_prop - TypeError: __init__() missing 1 required po...
FAILED tests_async/transport/test_aiohttp_requests.py::TestAuthorizedSession::test_request - TypeError: __init__() missing 1 requir...
FAILED tests_async/transport/test_aiohttp_requests.py::TestAuthorizedSession::test_ctx - TypeError: __init__() missing 1 required p...
FAILED tests_async/transport/test_aiohttp_requests.py::TestAuthorizedSession::test_http_headers - TypeError: __init__() missing 1 r...
FAILED tests_async/transport/test_aiohttp_requests.py::TestAuthorizedSession::test_regexp_example - TypeError: __init__() missing 1...
FAILED tests_async/transport/test_aiohttp_requests.py::TestAuthorizedSession::test_request_no_refresh - TypeError: __init__() missi...
FAILED tests_async/transport/test_aiohttp_requests.py::TestAuthorizedSession::test_request_refresh - TypeError: __init__() missing ...
============================================ 9 failed, 609 passed, 12 warnings in 33.41s =============================================

Here is the traceback for one of the failing tests:

____________________________________________ TestCombinedResponse.test_content_compressed ____________________________________________

self = <tests_async.transport.test_aiohttp_requests.TestCombinedResponse object at 0x108803160>
urllib3_mock = <function decompress at 0x10880a820>

    @mock.patch(
        "google.auth.transport._aiohttp_requests.urllib3.response.MultiDecoder.decompress",
        return_value="decompressed",
        autospec=True,
    )
    @pytest.mark.asyncio
    async def test_content_compressed(self, urllib3_mock):
        rm = core.RequestMatch(
            "url", headers={"Content-Encoding": "gzip"}, payload="compressed"
        )
>       response = await rm.build_response(core.URL("url"))

tests_async/transport/test_aiohttp_requests.py:72: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../../.virtualenv/google-auth-library-python/lib/python3.8/site-packages/aioresponses/core.py:192: in build_response
    resp = self._build_response(
../../../.virtualenv/google-auth-library-python/lib/python3.8/site-packages/aioresponses/core.py:173: in _build_response
    resp.content = stream_reader_factory(loop)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

loop = <Mock id='4437587472'>

    def stream_reader_factory(  # noqa
        loop: 'Optional[asyncio.AbstractEventLoop]' = None
    ):
        protocol = ResponseHandler(loop=loop)
>       return StreamReader(protocol, loop=loop)
E       TypeError: __init__() missing 1 required positional argument: 'limit'

../../../.virtualenv/google-auth-library-python/lib/python3.8/site-packages/aioresponses/compat.py:48: TypeError
========================================================== warnings summary ==========================================================

The root cause is a change in aiohttp version 3.7.0 which was released a few hours ago. The signature for StreamReader has changed, making the optional argument limit a required argument.

https://github.com/aio-libs/aiohttp/blob/56e78836aa7c67292ace9e256711699d51d57285/aiohttp/streams.py#L106

This change breaks aioresponses:

https://github.com/pnuckowski/aioresponses/blob/e61977f42a0164e0c572031dfb18ae95ba198df0/aioresponses/compat.py#L44

Activity

  1. davidwtbuxton commented on Oct 24, 2020

    @davidwtbuxton
    ContributorAuthor

    Potential fixes:

    • Wait for aiohttp to undo the change, making the limit argument optional again.
    • Wait for aioresponses to update so it is compatible with the changes in aiohttp.
    • Pin the version of aiohttp used when running tests <3.7.0.
  2. davidwtbuxton commented on Oct 24, 2020

    @davidwtbuxton
    ContributorAuthor

    I've made a PR for aioresponses pnuckowski/aioresponses#174

  3. tseaver commented on Oct 26, 2020

    @tseaver
    Contributor

    @davidwtbuxton Thanks for following up. I just added a comment to the aiohttp PR which made this breaking change.

  4. tseaver commented on Oct 26, 2020

    @tseaver
    Contributor
  5. added
    type: processA process-related concern. May include testing, release, or the like.
    and removed
    triage meI really want to be triaged.
    on Oct 26, 2020
  6. tseaver commented on Oct 28, 2020

    @tseaver
    Contributor

    PR #634 is merged. Perhaps we should leave this issue open with a change of title to indicate that we revisit the pin once aioresponses comes up with a release fixing the issue (the aiohttp maintainer says he doesn't consider his change breaking, as users aren't supposed to instantiate StreamResponse directly).

  7. changed the title [-]Tests for aiohttp_requests broken in master, TypeError exception[/-] [+]TODO: undo pin of 'aiohttp' once 'aioresponses' releases a fix[/+] on Oct 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

type: processA process-related concern. May include testing, release, or the like.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions