Skip to content

Fix test_loop_auto for Python 3.14 #2652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

musicinmybrain
Copy link

Summary

In Python 3.14, asyncio.events.BaseDefaultEventLoopPolicy, which was always a private/undocumented API, was renamed with a leading underscore. See python/cpython#131148.

This PR adapts test_loop_auto, which contains a type check against this undocumented type, to support either name depending on the interpreter version, fixing failures like the following on Python 3.14:

________________________________ test_loop_auto ________________________________

    def test_loop_auto():
        auto_loop_setup()
        policy = asyncio.get_event_loop_policy()
>       assert isinstance(policy, asyncio.events.BaseDefaultEventLoopPolicy)
E       AttributeError: module 'asyncio.events' has no attribute 'BaseDefaultEventLoopPolicy'

tests/test_auto_detection.py:38: AttributeError

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. (The change was to a test, so no new test was required.)
  • I've updated the documentation accordingly. (No documentation changes were needed.)

In Python 3.14, asyncio.events.BaseDefaultEventLoopPolicy, which was
always a private/undocumented API, was renamed with a leading
underscore. See python/cpython#131148.
This is probably less clear than the previous implementation, but it
should achieve the artificial metric of 100% test-line coverage.
@musicinmybrain musicinmybrain force-pushed the BaseDefaultEventLoopPolicy branch from c1cbd7f to 4287e25 Compare June 27, 2025 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant