Skip to content
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

Fix "There is no current event loop" in the asyncio test #236

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions irc/tests/test_client_aio.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import asyncio
import contextlib
import warnings
from unittest.mock import MagicMock

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


@contextlib.contextmanager
def suppress_issue_197():
with warnings.catch_warnings():
warnings.filterwarnings('ignore', 'There is no current event loop')
yield


def test_privmsg_sends_msg():
# create dummy transport, protocol
mock_transport = MagicMock()
mock_protocol = MagicMock()

# connect to dummy server
with suppress_issue_197():
loop = asyncio.get_event_loop()
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.create_connection = make_mocked_create_connection(
mock_transport, mock_protocol
)
Expand Down
Loading