Fix unawaited coroutine warning and treat as test error (#2806)

This commit is contained in:
Jeremiah Lowin 2026-01-07 14:29:56 -05:00 committed by GitHub
commit da965db5cb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 0 deletions

View file

@ -110,6 +110,9 @@ filterwarnings = [
# Suppress OAuth in-memory token storage warnings in tests
# Tests intentionally use ephemeral storage; this warning is for end users
"ignore:Using in-memory token storage:UserWarning",
# Treat unawaited coroutine warnings as errors - these are almost always bugs
"error:coroutine .* was never awaited:RuntimeWarning",
"error:Exception ignored in.*coroutine:pytest.PytestUnraisableExceptionWarning",
]
timeout = 5
env = [

View file

@ -686,6 +686,8 @@ class Client(Generic[ClientTransportT]):
# If session task already failed, raise immediately
if session_task.done():
# Close the coroutine to avoid "was never awaited" warning
coro.close()
exc = session_task.exception()
if exc:
raise exc