Skip to content

Commit 85fb8ea

Browse files
committed
fix(quart): Skip quart-flask-patch and adjust error test for quart>=0.23
quart-flask-patch is incompatible with quart>=0.23 due to RequestContext changes, so pin its dependency to <0.23 and skip the patch test above that version. Also update test_error_in_errorhandler: since 0.23 (db05772), Quart runs request handling inside an asyncio.TaskGroup, so exceptions propagate wrapped in an ExceptionGroup instead of bare. Fixes PY-2754 Fixes #7305
1 parent 58823cc commit 85fb8ea

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

scripts/populate_tox/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@
399399
"package": "quart",
400400
"deps": {
401401
"*": ["quart-auth", "pytest-asyncio", "pytest-forked", "Werkzeug"],
402-
">=0.19": ["quart-flask-patch"],
402+
">=0.19,<0.23": ["quart-flask-patch"],
403403
"<0.19": [
404404
"blinker<1.6",
405405
"jinja2<3.1.0",

tests/integrations/quart/test_quart.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ def integration_enabled_params(request):
9292
sys.version_info >= (3, 14),
9393
reason="quart_flask_patch not working on 3.14 (yet?)",
9494
)
95+
@pytest.mark.skipif(
96+
QUART_VERSION >= (0, 23),
97+
reason="quart_flask_patch is incompatible with quart>=0.23 RequestContext changes",
98+
)
9599
async def test_quart_flask_patch(sentry_init, capture_events, reset_integrations):
96100
# This testcase is forked because `import quart_flask_patch` needs to run
97101
# before anything else Quart-related is imported (since it monkeypatches
@@ -417,6 +421,28 @@ async def error_handler(err):
417421
(exception,) = event["exception"]["values"]
418422
assert exception["type"] == "ValueError"
419423

424+
elif QUART_VERSION >= (0, 23):
425+
# Starting in 0.23 (db05772), Quart runs request handling inside an
426+
# asyncio.TaskGroup, so the ZeroDivisionError propagates wrapped
427+
# in an ExceptionGroup instead of bare.
428+
with pytest.raises(ExceptionGroup) as exc_info: # noqa: F821
429+
await client.get("/")
430+
431+
(exception,) = exc_info.value.exceptions
432+
assert isinstance(exception, ZeroDivisionError)
433+
434+
event1, event2 = events
435+
436+
(exception,) = event1["exception"]["values"]
437+
assert exception["type"] == "ValueError"
438+
439+
# event2's exception chain is [ValueError, ZeroDivisionError,
440+
# ExceptionGroup]: the ValueError that triggered the errorhandler,
441+
# the ZeroDivisionError raised inside it, and the ExceptionGroup
442+
# Quart's TaskGroup wraps them in.
443+
exception_types = [e["type"] for e in event2["exception"]["values"]]
444+
assert exception_types == ["ValueError", "ZeroDivisionError", "ExceptionGroup"]
445+
420446
else:
421447
with pytest.raises(ZeroDivisionError):
422448
await client.get("/")

0 commit comments

Comments
 (0)