test(gapic-generator): Update gapic generator to resolve pytest-asyncio errors.#17260
Conversation
… in gapic-generator templates
…emplates and integration goldens
…ldens with grpcio 1.59.0
…yncio loop RuntimeError in unit tests
…-rest constraints template
…vent loop fixture and async-rest constraints updates
…-3.14.txt and add pip freeze logger
There was a problem hiding this comment.
Code Review
This pull request updates dependencies (such as bumping grpcio and adding pytest-asyncio), adjusts constraints file resolution logic in noxfile.py.j2, and introduces an autouse fixture to manage the asyncio event loop in generated unit tests. Feedback from the reviewer highlights three main areas of improvement: first, the specified version of pytest-asyncio>=1.3.0 does not exist on PyPI and will cause installation failures; second, the use of asyncio.get_event_loop() is deprecated and can leak resources, which can be resolved by using the event loop policy and cleanly closing newly created loops; and third, the constraints file resolution logic in noxfile.py.j2 can be simplified and made more robust by directly checking for the file's existence.
No region tags are edited in this PR.This comment is generated by snippet-bot.
|
…ale selective logging_internal golden snippets
…loop autouse fixture inside tests template
| @pytest.fixture(autouse=True) | ||
| def set_event_loop(): | ||
| try: | ||
| asyncio.get_event_loop_policy().get_event_loop() |
There was a problem hiding this comment.
There's a deprecation warning in the logs:
test_messaging.py:121: DeprecationWarning: 'asyncio.get_event_loop_policy' is deprecated and slated for removal in Python 3.16
Is there a different method we should use as the default?
There was a problem hiding this comment.
Great question.
We have an alternate solution. Gonna regen the goldens and update this snippet.
There was a problem hiding this comment.
Resolved.
get_running_loop() is the modern, standard API that avoids deprecation warnings on Python 3.10+ and remains supported in future Python 3.16+ runtimes!
…plate to prevent Python 3.16 deprecation warnings
This PR updates the Python GAPIC generator templates to support modern EOL Python support drops natively across the entire SDK.
Changes
grpciodependency requirement to>= 1.59.0. This robust minimum requirement resolves thepytest-asyncioevent loop regressions universally, removing the need for custompytest-asynciooverrides.testing/constraints-3.10.txt).pytest-asynciofailures across Python runtimes 3.10 - 3.14.