Skip to content

Commit 074b807

Browse files
committed
Fix "There is no current event loop" in the asyncio test
This bug is causing the test to fail under Python 3.14. Fix it by calling asyncio.new_event_loop() and asyncio.set_event_loop() as recommended in: https://stackoverflow.com/a/73367187 Fixes #197
1 parent ff26bfd commit 074b807

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

irc/tests/test_client_aio.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import asyncio
2-
import contextlib
3-
import warnings
42
from unittest.mock import MagicMock
53

64
from irc import client_aio
@@ -13,21 +11,14 @@ async def mock_create_connection(*args, **kwargs):
1311
return mock_create_connection
1412

1513

16-
@contextlib.contextmanager
17-
def suppress_issue_197():
18-
with warnings.catch_warnings():
19-
warnings.filterwarnings('ignore', 'There is no current event loop')
20-
yield
21-
22-
2314
def test_privmsg_sends_msg():
2415
# create dummy transport, protocol
2516
mock_transport = MagicMock()
2617
mock_protocol = MagicMock()
2718

2819
# connect to dummy server
29-
with suppress_issue_197():
30-
loop = asyncio.get_event_loop()
20+
loop = asyncio.new_event_loop()
21+
asyncio.set_event_loop(loop)
3122
loop.create_connection = make_mocked_create_connection(
3223
mock_transport, mock_protocol
3324
)

0 commit comments

Comments
 (0)