GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-128404: Run TestGetAsyncGenState without asyncio by graingert · Pull Request #156808 · python/cpython

Conversation

@graingert

@graingert graingert commented Sep 2, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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.

  • Issue: Remove un-necessary socket requirements in async tests #128404

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@graingert
pythongh-128404: Run TestGetAsyncGenState without asyncio
2a63aec
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.
@bedevere-app bedevere-app Bot added the tests Tests in the Lib/test dir label Sep 2, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Sep 2, 2026
Remove un-necessary socket requirements in async tests #128404
Open
@graingert graingert added skip news and removed tests Tests in the Lib/test dir labels Sep 2, 2026
@graingert
Split the fixture-free tests out of TestGetAsyncGenState
65292e5
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.
@graingert
graingert requested a review from Eclips4 September 2, 2026 09:07
@graingert
graingert marked this pull request as ready for review September 2, 2026 09:07
@bedevere-app bedevere-app Bot added the awaiting review label Sep 2, 2026
@johnslavik

johnslavik commented Sep 2, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@johnslavik

johnslavik commented Sep 2, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Oh, right. I rewrote the decorator as _async_test = partial(partial, run_yielding_async_fn). Who doesn't love partial partials.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@graingert

graingert commented Sep 2, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@graingert

graingert commented Sep 2, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@graingert

graingert commented Sep 2, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

@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
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@graingert
Merge branch 'main' into inspect-asyncgen-state-without-asyncio
caadbf7
@ambv ambv mentioned this pull request Oct 20, 2026
gh-128404: split test_asyncgen.py into tests that require a working socket and tests that do not #128443
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@Eclips4 Eclips4 Awaiting requested review from Eclips4

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting review skip news

Projects

None yet

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.

2 participants

@graingert @johnslavik
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.