Test case 'test_privmsg_sends_msg' failure: RuntimeError: There is no current event loop in thread 'MainThread'.

Open Beginner friendly
#246 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
62/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
testing-qa

Research direction

The failing call is asyncio.get_event_loop() at irc/tests/test_client_aio.py line 30 inside test_privmsg_sends_msg, which runs under the suppress_issue_197() context manager. Start by reading that test and the helper, then run python3 -m pytest irc/tests/test_client_aio.py::test_privmsg_sends_msg on Python 3.14 to reproduce. Done means the test passes on 3.14 without deprecated loop access, and the rest of the suite still passes.

Written by the indexing model from the issue text.

Description

When running the test suite on a minimal install of the package (source release “20.5.0”), the test case 'test_privmsg_sends_msg' fails:

$ python3 --version
Python 3.14.8

$ python3 -m pytest
============================= test session starts ==============================
platform linux -- Python 3.14.8, pytest-9.1.1, pluggy-1.6.0
rootdir: /build/reproducible-path/python-irc-20.5.0+dfsg1/.pybuild/cpython3_3.14_irc/build
configfile: pytest.ini
plugins: typeguard-4.4.4
collected 36 items / 2 deselected / 34 selected

[…]
=================================== FAILURES ===================================
____________________________ test_privmsg_sends_msg ____________________________

    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()
                   ^^^^^^^^^^^^^^^^^^^^^^^^

irc/tests/test_client_aio.py:30:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <asyncio.unix_events._UnixDefaultEventLoopPolicy object at 0x7f27a9570ad0>

    def get_event_loop(self):
        """Get the event loop for the current context.

        Returns an instance of EventLoop or raises an exception.
        """
        if self._local._loop is None:
>           raise RuntimeError('There is no current event loop in thread %r.'
                               % threading.current_thread().name)
E           RuntimeError: There is no current event loop in thread 'MainThread'.

/usr/lib/python3.14/asyncio/events.py:718: RuntimeError
[…]
Dominant language
Python
Stars
422
Forks
91
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from jaraco/irc

All issues in jaraco/irc

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.