projects/aports·blob master · refs

51 lines · 1.6 KiB

1Patch-Source: https://github.com/jaraco/irc/pull/236
2---
3From 074b807361164e1522b64a225f4647a8b4bb53b8 Mon Sep 17 00:00:00 2001
4From: =?UTF-8?q?Ondrej=20Mosn=C3=A1=C4=8Dek?= <[email protected]>
5Date: Sat, 23 Nov 2024 10:25:44 +0100
6Subject: [PATCH] Fix "There is no current event loop" in the asyncio test
7
8This bug is causing the test to fail under Python 3.14. Fix it by
9calling asyncio.new_event_loop() and asyncio.set_event_loop() as
10recommended in: https://stackoverflow.com/a/73367187
11
12Fixes #197
13---
14 irc/tests/test_client_aio.py | 13 ++-----------
15 1 file changed, 2 insertions(+), 11 deletions(-)
16
17diff --git a/irc/tests/test_client_aio.py b/irc/tests/test_client_aio.py
18index 962cbde..00a02f6 100644
19--- a/irc/tests/test_client_aio.py
20+++ b/irc/tests/test_client_aio.py
21@@ -1,6 +1,4 @@
22 import asyncio
23-import contextlib
24-import warnings
25 from unittest.mock import MagicMock
26
27 from irc import client_aio
28@@ -13,21 +11,14 @@ async def mock_create_connection(*args, **kwargs):
29 return mock_create_connection
30
31
32-@contextlib.contextmanager
33-def suppress_issue_197():
34- with warnings.catch_warnings():
35- warnings.filterwarnings('ignore', 'There is no current event loop')
36- yield
37-
38-
39 def test_privmsg_sends_msg():
40 # create dummy transport, protocol
41 mock_transport = MagicMock()
42 mock_protocol = MagicMock()
43
44 # connect to dummy server
45- with suppress_issue_197():
46- loop = asyncio.get_event_loop()
47+ loop = asyncio.new_event_loop()
48+ asyncio.set_event_loop(loop)
49 loop.create_connection = make_mocked_create_connection(
50 mock_transport, mock_protocol
51 )