From 664ceba2c5597c321ef69d0325cf108843c4ab87 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 17 Dec 2025 07:11:32 +0000 Subject: [PATCH] Fix TestSyncifyAsyncContext.test_sync_acontext on Python 3.14 (#4722) `asyncio.get_event_loop` fails on Python 3.14 if there is no current event loop. For this particular test of sync behaviour, it seems to make most sense to explicitly create one. --- tests/telethon/test_helpers.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/telethon/test_helpers.py b/tests/telethon/test_helpers.py index 3dffdf66..a391f28c 100644 --- a/tests/telethon/test_helpers.py +++ b/tests/telethon/test_helpers.py @@ -2,6 +2,7 @@ tests for telethon.helpers """ +import asyncio from base64 import b64decode import pytest @@ -39,9 +40,9 @@ def test_strip_text(): class TestSyncifyAsyncContext: class NoopContextManager: - def __init__(self): + def __init__(self, loop=None): self.count = 0 - self.loop = helpers.get_running_loop() + self.loop = loop or helpers.get_running_loop() async def __aenter__(self): self.count += 1 @@ -55,7 +56,7 @@ class TestSyncifyAsyncContext: __exit__ = helpers._sync_exit def test_sync_acontext(self): - contm = self.NoopContextManager() + contm = self.NoopContextManager(loop=asyncio.new_event_loop()) assert contm.count == 0 with contm: