googleapis / python-firestore

Apache License 2.0
218 stars 75 forks source link

`prerelease_deps` session with `coroutine 'UnaryUnaryCall._invoke' was never awaited` with `pytest-asyncio>0.21.2` #954

Open parthea opened 2 months ago

parthea commented 2 months ago

See build log here where the presubmit Kokoro Prerelease Dependencies which runs the prerelease_deps nox session fails with RuntimeWarning: coroutine 'UnaryUnaryCall._invoke' was never awaited

The issue only appears when using pytest-asyncio>0.21.2

tests/system/test_system_async.py::test_or_query_in_transaction[None] ERROR                                                                                                                                                                        [ 49%]
tests/system/test_system.py::test_collections[system-tests-named-db] Exception ignored in: <coroutine object UnaryUnaryCall._invoke at 0x7f0eb26a5380>
Traceback (most recent call last):
  File "/usr/local/google/home/partheniou/.pyenv/versions/3.12.0/lib/python3.12/warnings.py", line 552, in _warn_unawaited_coroutine
    warn(msg, category=RuntimeWarning, stacklevel=2, source=coro)
RuntimeWarning: coroutine 'UnaryUnaryCall._invoke' was never awaited
FAILED
daniel-sanche commented 2 months ago

This is related to https://github.com/pytest-dev/pytest-asyncio/releases/tag/v0.23.8

"As of v0.23, pytest-asyncio attaches an asyncio event loop to each item of the test suite (i.e. session, packages, modules, classes, functions) and allows tests to be run in those loops when marked accordingly. Pytest-asyncio currently assumes that async fixture scope is correlated with the new event loop scope. This prevents fixtures from being evaluated independently from the event loop scope and breaks some existing test suites"

It looks like 0.24.0 is changing how event loops are handled again, so maybe it will help