etianen / aiohttp-wsgi

WSGI adapter for aiohttp.
https://aiohttp-wsgi.readthedocs.io
BSD 3-Clause "New" or "Revised" License
232 stars 20 forks source link

EnvironTest.testEnviron fails with aiohttp 3.8.1 #32

Closed mweinelt closed 2 years ago

mweinelt commented 2 years ago

We've upgraded to aiohttp>=3.8.0 recently in nixpkgs and I noticed this package now fails the following test:

___________________________ EnvironTest.testEnviron ____________________________

self = <tests.test_environ.EnvironTest testMethod=testEnviron>

    def testEnviron(self) -> None:
        with self.run_server(assert_environ) as client:
>           client.assert_response(headers={
                "Foo": "bar",
            })

tests/test_environ.py:99: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/base.py:43: in assert_response
    self._test_case.assertEqual(response.status, 200)
E   AssertionError: 500 != 200
------------------------------ Captured log call -------------------------------
ERROR    aiohttp.server:web_protocol.py:405 Error handling request
Traceback (most recent call last):
  File "/nix/store/cpi0v7m6l2y47banahzihgpca47diryv-python3.9-aiohttp-3.8.1/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/nix/store/cpi0v7m6l2y47banahzihgpca47diryv-python3.9-aiohttp-3.8.1/lib/python3.9/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/build/source/aiohttp_wsgi/wsgi.py", line 294, in handle_request
    return await self._loop.run_in_executor(
  File "/nix/store/nffa4bgyi43wcrw3g3z0cmwy9zzz528y-python3-3.9.6/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/build/source/aiohttp_wsgi/wsgi.py", line 147, in _run_application
    body_iterable = application(environ, start_response)
  File "/build/source/tests/test_environ.py", line 13, in do_environ_application
    func(environ)
  File "/build/source/tests/test_environ.py", line 23, in assert_environ
    assert environ["CONTENT_TYPE"] == ""
AssertionError: assert 'application/octet-stream' == ''
  + application/octet-stream
etianen commented 2 years ago

I don't really understand how nixpkgs runs tests. Does it fail on the first test? Or were multiple tests failing?

etianen commented 2 years ago

Ah, I see, this looks like a bug with aiohttp 3.8.0+, like you say.

It's only the tests that are failing, so this isn't massively urgent. But it would be good to get to the bottom of whether the aiohttp client or server has changed here. It would also be good to figure out how to best update the test.

I don't have the time to look at this this week. I'd take a MR that investigates this and fixes the test, if it's breaking your workflow.