tests/middleware/test_wsgi.py::test_wsgi_exception fails with anyio 3.7.1 #2228
-
As of 0.31.0 release, the following test fails with anyio 3.7.1 version. FWICS it passes with the git version. $ python -m pytest -Wignore
========================================================= test session starts =========================================================
platform linux -- Python 3.11.4, pytest-7.4.0, pluggy-1.2.0
rootdir: /tmp/starlette
configfile: pyproject.toml
plugins: anyio-3.7.1
collected 752 items
tests/test__utils.py ...... [ 0%]
tests/test_applications.py ................................................ [ 7%]
tests/test_authentication.py ........... [ 8%]
tests/test_background.py ........ [ 9%]
tests/test_concurrency.py .... [ 10%]
tests/test_config.py .... [ 10%]
tests/test_convertors.py ...... [ 11%]
tests/test_datastructures.py .......................... [ 15%]
tests/test_endpoints.py .................... [ 17%]
tests/test_exceptions.py ..................... [ 20%]
tests/test_formparsers.py .................................................................... [ 29%]
tests/test_requests.py ............................................................................... [ 40%]
tests/test_responses.py .............................................................. [ 48%]
tests/test_routing.py ................................................................................. [ 59%]
tests/test_schemas.py ... [ 59%]
tests/test_staticfiles.py .................................................... [ 66%]
tests/test_status.py .. [ 66%]
tests/test_templates.py ...................... [ 69%]
tests/test_testclient.py ..................................... [ 74%]
tests/test_websockets.py ............................................................... [ 82%]
tests/middleware/test_base.py .........x.x................................... [ 89%]
tests/middleware/test_cors.py .............................. [ 93%]
tests/middleware/test_errors.py ............ [ 94%]
tests/middleware/test_gzip.py .......... [ 96%]
tests/middleware/test_https_redirect.py .. [ 96%]
tests/middleware/test_middleware.py . [ 96%]
tests/middleware/test_session.py ............ [ 98%]
tests/middleware/test_trusted_host.py ..... [ 98%]
tests/middleware/test_wsgi.py ....FF.... [100%]
============================================================== FAILURES ===============================================================
____________________________________________________ test_wsgi_exception[asyncio] _____________________________________________________
test_client_factory = functools.partial(<class 'starlette.testclient.TestClient'>, backend='asyncio', backend_options={})
def test_wsgi_exception(test_client_factory):
# Note that we're testing the WSGI app directly here.
# The HTTP protocol implementations would catch this error and return 500.
app = WSGIMiddleware(raise_exception)
client = test_client_factory(app)
with pytest.raises(ExceptionGroup) as exc:
> client.get("/")
tests/middleware/test_wsgi.py:73:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
starlette/testclient.py:502: in get
return super().get(
.venv/lib/python3.11/site-packages/httpx/_client.py:1041: in get
return self.request(
starlette/testclient.py:468: in request
return super().request(
.venv/lib/python3.11/site-packages/httpx/_client.py:814: in request
return self.send(request, auth=auth, follow_redirects=follow_redirects)
.venv/lib/python3.11/site-packages/httpx/_client.py:901: in send
response = self._send_handling_auth(
.venv/lib/python3.11/site-packages/httpx/_client.py:929: in _send_handling_auth
response = self._send_handling_redirects(
.venv/lib/python3.11/site-packages/httpx/_client.py:966: in _send_handling_redirects
response = self._send_single_request(request)
.venv/lib/python3.11/site-packages/httpx/_client.py:1002: in _send_single_request
response = transport.handle_request(request)
starlette/testclient.py:344: in handle_request
raise exc
starlette/testclient.py:341: in handle_request
portal.call(self.app, scope, receive, send)
.venv/lib/python3.11/site-packages/anyio/from_thread.py:277: in call
return cast(T_Retval, self.start_task_soon(func, *args).result())
/usr/lib/python3.11/concurrent/futures/_base.py:456: in result
return self.__get_result()
/usr/lib/python3.11/concurrent/futures/_base.py:401: in __get_result
raise self._exception
.venv/lib/python3.11/site-packages/anyio/from_thread.py:217: in _call_func
retval = await retval
starlette/middleware/wsgi.py:72: in __call__
await responder(receive, send)
starlette/middleware/wsgi.py:102: in __call__
await anyio.to_thread.run_sync(self.wsgi, environ, self.start_response)
.venv/lib/python3.11/site-packages/anyio/to_thread.py:33: in run_sync
return await get_asynclib().run_sync_in_worker_thread(
.venv/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:877: in run_sync_in_worker_thread
return await future
.venv/lib/python3.11/site-packages/anyio/_backends/_asyncio.py:807: in run
result = context.run(func, *args)
starlette/middleware/wsgi.py:140: in wsgi
for chunk in self.app(environ, start_response):
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
environ = {'HTTP_ACCEPT': '*/*', 'HTTP_ACCEPT_ENCODING': 'gzip, deflate', 'HTTP_CONNECTION': 'keep-alive', 'HTTP_HOST': 'testserver', ...}
start_response = <bound method WSGIResponder.start_response of <starlette.middleware.wsgi.WSGIResponder object at 0x7fc53076bb10>>
def raise_exception(environ, start_response):
> raise RuntimeError("Something went wrong")
E RuntimeError: Something went wrong
tests/middleware/test_wsgi.py:34: RuntimeError
______________________________________________________ test_wsgi_exception[trio] ______________________________________________________
test_client_factory = functools.partial(<class 'starlette.testclient.TestClient'>, backend='trio', backend_options={})
def test_wsgi_exception(test_client_factory):
# Note that we're testing the WSGI app directly here.
# The HTTP protocol implementations would catch this error and return 500.
app = WSGIMiddleware(raise_exception)
client = test_client_factory(app)
with pytest.raises(ExceptionGroup) as exc:
> client.get("/")
tests/middleware/test_wsgi.py:73:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
starlette/testclient.py:502: in get
return super().get(
.venv/lib/python3.11/site-packages/httpx/_client.py:1041: in get
return self.request(
starlette/testclient.py:468: in request
return super().request(
.venv/lib/python3.11/site-packages/httpx/_client.py:814: in request
return self.send(request, auth=auth, follow_redirects=follow_redirects)
.venv/lib/python3.11/site-packages/httpx/_client.py:901: in send
response = self._send_handling_auth(
.venv/lib/python3.11/site-packages/httpx/_client.py:929: in _send_handling_auth
response = self._send_handling_redirects(
.venv/lib/python3.11/site-packages/httpx/_client.py:966: in _send_handling_redirects
response = self._send_single_request(request)
.venv/lib/python3.11/site-packages/httpx/_client.py:1002: in _send_single_request
response = transport.handle_request(request)
starlette/testclient.py:344: in handle_request
raise exc
starlette/testclient.py:341: in handle_request
portal.call(self.app, scope, receive, send)
.venv/lib/python3.11/site-packages/anyio/from_thread.py:277: in call
return cast(T_Retval, self.start_task_soon(func, *args).result())
/usr/lib/python3.11/concurrent/futures/_base.py:456: in result
return self.__get_result()
/usr/lib/python3.11/concurrent/futures/_base.py:401: in __get_result
raise self._exception
.venv/lib/python3.11/site-packages/anyio/from_thread.py:217: in _call_func
retval = await retval
starlette/middleware/wsgi.py:72: in __call__
await responder(receive, send)
starlette/middleware/wsgi.py:102: in __call__
await anyio.to_thread.run_sync(self.wsgi, environ, self.start_response)
.venv/lib/python3.11/site-packages/anyio/to_thread.py:33: in run_sync
return await get_asynclib().run_sync_in_worker_thread(
.venv/lib/python3.11/site-packages/anyio/_backends/_trio.py:230: in run_sync_in_worker_thread
return await run_sync(
.venv/lib/python3.11/site-packages/trio/_threads.py:227: in to_thread_run_sync
return await trio.lowlevel.wait_task_rescheduled(abort)
.venv/lib/python3.11/site-packages/trio/_core/_traps.py:173: in wait_task_rescheduled
return (await _async_yield(WaitTaskRescheduled(abort_func))).unwrap()
.venv/lib/python3.11/site-packages/outcome/_impl.py:138: in unwrap
raise captured_error
.venv/lib/python3.11/site-packages/trio/_threads.py:168: in do_release_then_return_result
return result.unwrap()
.venv/lib/python3.11/site-packages/outcome/_impl.py:138: in unwrap
raise captured_error
.venv/lib/python3.11/site-packages/trio/_threads.py:185: in worker_fn
ret = sync_fn(*args)
.venv/lib/python3.11/site-packages/anyio/_backends/_trio.py:225: in wrapper
return func(*args)
starlette/middleware/wsgi.py:140: in wsgi
for chunk in self.app(environ, start_response):
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
environ = {'HTTP_ACCEPT': '*/*', 'HTTP_ACCEPT_ENCODING': 'gzip, deflate', 'HTTP_CONNECTION': 'keep-alive', 'HTTP_HOST': 'testserver', ...}
start_response = <bound method WSGIResponder.start_response of <starlette.middleware.wsgi.WSGIResponder object at 0x7fc530c38ad0>>
def raise_exception(environ, start_response):
> raise RuntimeError("Something went wrong")
E RuntimeError: Something went wrong
tests/middleware/test_wsgi.py:34: RuntimeError
======================================================= short test summary info =======================================================
XFAIL tests/middleware/test_base.py::test_contextvars[asyncio-CustomMiddlewareUsingBaseHTTPMiddleware] - BaseHTTPMiddleware creates a TaskGroup which copies the contextand erases any changes to it made within the TaskGroup
XFAIL tests/middleware/test_base.py::test_contextvars[trio-CustomMiddlewareUsingBaseHTTPMiddleware] - BaseHTTPMiddleware creates a TaskGroup which copies the contextand erases any changes to it made within the TaskGroup
============================================== 2 failed, 748 passed, 2 xfailed in 27.28s ============================================== |
Beta Was this translation helpful? Give feedback.
Answered by
mgorny
Aug 27, 2023
Replies: 1 comment 1 reply
-
It seems to be fixed in 0.31.1. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
mgorny
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It seems to be fixed in 0.31.1.