Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.8.6: test_request_tracing_url_params fails #7766

Open
1 task done
mtelka opened this issue Oct 30, 2023 · 0 comments
Open
1 task done

3.8.6: test_request_tracing_url_params fails #7766

mtelka opened this issue Oct 30, 2023 · 0 comments
Labels

Comments

@mtelka
Copy link
Contributor

mtelka commented Oct 30, 2023

Describe the bug

I'm runnig tests for aiohttp 3.8.6 on OpenIndiana and I see that test_request_tracing_url_params test fails.

This seems to be related to #7259.

To Reproduce

Run aiohttp test.

Expected behavior

All tests pass.

Logs/tracebacks

___________________ test_request_tracing_url_params[pyloop] ____________________

loop = <_UnixSelectorEventLoop running=False closed=False debug=False>
aiohttp_client = <function aiohttp_client.<locals>.go at 0x7fffaa7898b0>

    async def test_request_tracing_url_params(loop: Any, aiohttp_client: Any) -> None:
        async def root_handler(request):
            return web.Response()

        async def redirect_handler(request):
            raise web.HTTPFound("/")

        app = web.Application()
        app.router.add_get("/", root_handler)
        app.router.add_get("/redirect", redirect_handler)

        mocks = [mock.Mock(side_effect=make_mocked_coro(mock.Mock())) for _ in range(7)]
        (   
            on_request_start,
            on_request_redirect,
            on_request_end,
            on_request_exception,
            on_request_chunk_sent,
            on_response_chunk_received,
            on_request_headers_sent,
        ) = mocks

        trace_config = aiohttp.TraceConfig(
            trace_config_ctx_factory=mock.Mock(return_value=mock.Mock())
        )
        trace_config.on_request_start.append(on_request_start)
        trace_config.on_request_redirect.append(on_request_redirect)
        trace_config.on_request_end.append(on_request_end)
        trace_config.on_request_exception.append(on_request_exception)
        trace_config.on_request_chunk_sent.append(on_request_chunk_sent)
        trace_config.on_response_chunk_received.append(on_response_chunk_received)
        trace_config.on_request_headers_sent.append(on_request_headers_sent)

        session = await aiohttp_client(app, trace_configs=[trace_config])

        def reset_mocks() -> None:
            for m in mocks:
                m.reset_mock()

        def to_trace_urls(mock_func: mock.Mock) -> List[URL]:
            return [call_args[0][-1].url for call_args in mock_func.call_args_list]

        def to_url(path: str) -> URL:
            return session.make_url(path)

        # Standard
        for req in [
            lambda: session.get("/?x=0"),
            lambda: session.get("/", params=dict(x=0)),
        ]:
            reset_mocks()
            async with req() as resp:
                await resp.text()
>               assert to_trace_urls(on_request_start) == [to_url("/?x=0")]
E               AssertionError: assert [URL('http://127.0.0.1:41992/')] == [URL('http://127.0.0.1:41992/?x=0')]
E                 At index 0 diff: URL('http://127.0.0.1:41992/') != URL('http://127.0.0.1:41992/?x=0')
E                 Full diff:
E                 - [URL('http://127.0.0.1:41992/?x=0')]
E                 ?                              ----
E                 + [URL('http://127.0.0.1:41992/')]

aiohttp_client = <function aiohttp_client.<locals>.go at 0x7fffaa7898b0>
app        = <Application 0x7fffa9e48610>
loop       = <_UnixSelectorEventLoop running=False closed=False debug=False>
mocks      = [<Mock id='140736049833392'>,
 <Mock id='140736049833104'>,
 <Mock id='140736050092256'>,
 <Mock id='140736050091248'>,
 <Mock id='140736050091680'>,
 <Mock id='140736050090336'>,
 <Mock id='140736050090672'>]
on_request_chunk_sent = <Mock id='140736050091680'>
on_request_end = <Mock id='140736050092256'>
on_request_exception = <Mock id='140736050091248'>
on_request_headers_sent = <Mock id='140736050090672'>
on_request_redirect = <Mock id='140736049833104'>
on_request_start = <Mock id='140736049833392'>
on_response_chunk_received = <Mock id='140736050090336'>
redirect_handler = <function test_request_tracing_url_params.<locals>.redirect_handler at 0x7fffa9d51700>
req        = <function test_request_tracing_url_params.<locals>.<lambda> at 0x7fffaa560820>
reset_mocks = <function test_request_tracing_url_params.<locals>.reset_mocks at 0x7fffaa560af0>
resp       = <ClientResponse(http://127.0.0.1:41992/?x=0) [200 OK]>
<CIMultiDictProxy('Content-Length': '0', 'Content-Type': 'application/octet-stream', 'Date': 'Mon, 30 Oct 2023 13:38:00 GMT', 'Server': 'Python/3.9 aiohttp/3.8.6')>

root_handler = <function test_request_tracing_url_params.<locals>.root_handler at 0x7fffaa789940>
session    = <aiohttp.test_utils.TestClient object at 0x7fffaa45df70>
to_trace_urls = <function test_request_tracing_url_params.<locals>.to_trace_urls at 0x7fffaa5609d0>
to_url     = <function test_request_tracing_url_params.<locals>.to_url at 0x7fffaa5608b0>
trace_config = <aiohttp.tracing.TraceConfig object at 0x7fffaa45d9d0>

tests/test_client_session.py:669: AssertionError

Python Version

$ python --version
Python 3.9.16

aiohttp Version

$ python -m pip show aiohttp
3.8.6

multidict Version

$ python -m pip show multidict
6.0.4

yarl Version

$ python -m pip show yarl
1.9.2

OS

OpenIndiana

Related component

Server, Client

Additional context

No response

Code of Conduct

  • I agree to follow the aio-libs Code of Conduct
@mtelka mtelka added the bug label Oct 30, 2023
@mtelka mtelka changed the title 3.8.5: test_request_tracing_url_params fails 3.8.6: test_request_tracing_url_params fails Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant