GeezerVison is showing github.com — gh-128404: Run TestGetAsyncGenState without asyncio by graingert · Pull Request #156808 · python/cpython
Conversation
graingert
commented
Sep 2, 2026
•
edited by bedevere-app
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
inspect.getasyncgenstate() and getasyncgenlocals() are pure introspection: none of the awaits in these tests suspend, so the class does not need an event loop and does not need to be skipped when there is no working socket.
Drive the coroutines with support.run_no_yield_async_fn() instead, as the neighbouring TestGetCoroutineState already does, using the same _async_test decorator as test_contextlib_async. This also drops the last use of asyncio in the module.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
inspect.getasyncgenstate() and getasyncgenlocals() are pure
introspection: none of the awaits in these tests suspend, so the class
does not need an event loop and does not need to be skipped when there
is no working socket.
Drive the coroutines with support.run_no_yield_async_fn() instead, as
the neighbouring TestGetCoroutineState already does, using the same
_async_test decorator as test_contextlib_async. This also drops the
last use of asyncio in the module.
test_easy_debugging and the three getasyncgenlocals tests never touch
the async generator built by setUp; they built their own or used none
at all. Move them to TestGetAsyncGenLocals, which needs no fixture.
johnslavik
commented
Sep 2, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
Maybe we should move this helper to somewhere in test.support? #155127 will also use it.
We'll have 3 test modules using @_async_test.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
johnslavik
commented
Sep 2, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
Oh, right. I rewrote the decorator as _async_test = partial(partial, run_yielding_async_fn). Who doesn't love partial partials.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
graingert
commented
Sep 2, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
it needs functools.wraps to copy in flags such as __unittest_skip__ = True and
__unittest_skip_why__ = reason
edit: I suppose you can put the skipIf/skip decorator on top of the @_async_test decorator
Oh, right. I rewrote the decorator as _async_test = partial(partial, run_yielding_async_fn). Who doesn't love partial partials.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
graingert
commented
Sep 2, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
my @_async_test uses run_no_yield_async_fn but your @_async_test uses run_yielding_async_fn so I think they're different enough to be defined per module
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
graingert
commented
Sep 2, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
@johnslavik I checked the test code and it never calls async_yield so it can (and should) be run with run_no_yield_async_fn see #155127 (comment) so I'm happy to have a central @async_test decorator defined in test.support
We should probably wait for these two PRs to merge before doing the refactor though
|
johnslavik reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
Eclips4
Awaiting requested review from Eclips4
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|