jaraco / irc

Full-featured Python IRC library for Python.
MIT License
390 stars 84 forks source link

irc/tests/test_client_aio.py::test_privmsg_sends_msg fails with Python 3.8.1 #165

Closed sbraz closed 3 years ago

sbraz commented 4 years ago

Hi Jason, For some reason, this test that works fine with Python 3.6 and 3.7 fails with 3.8:

irc/tests/test_client_aio.py::test_privmsg_sends_msg FAILED                                                                                                                                                 [100%]

==================================================================================================== FAILURES =====================================================================================================
_____________________________________________________________________________________________ test_privmsg_sends_msg ______________________________________________________________________________________________

create_connection_mock = <AsyncMock name='create_connection' id='139851493685856'>

    @patch('asyncio.base_events.BaseEventLoop.create_connection')
    def test_privmsg_sends_msg(create_connection_mock):
        # create dummy transport, protocol
        fake_connection = asyncio.Future()

        mock_transport = MagicMock()
        mock_protocol = MagicMock()

        fake_connection.set_result((mock_transport, mock_protocol))
        create_connection_mock.return_value = fake_connection

        # connect to dummy server
        loop = asyncio.get_event_loop()
        server = client_aio.AioReactor(loop=loop).server()
>       loop.run_until_complete(server.connect('foo', 6667, 'my_irc_nick'))

irc/tests/test_client_aio.py:21: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/asyncio/base_events.py:612: in run_until_complete
    return future.result()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <irc.client_aio.AioConnection object at 0x7f31b69be8b0>, server = 'foo', port = 6667, nickname = 'my_irc_nick', password = None, username = None, ircname = None
connect_factory = <irc.connection.AioFactory object at 0x7f31b6a96f40>

    async def connect(
        self,
        server,
        port,
        nickname,
        password=None,
        username=None,
        ircname=None,
        connect_factory=connection.AioFactory(),
    ):
        """Connect/reconnect to a server.

        Arguments:

        * server - Server name
        * port - Port number
        * nickname - The nickname
        * password - Password (if any)
        * username - The username
        * ircname - The IRC name ("realname")

        * connect_factory - An async callable that takes the event loop and the
          server address, and returns a connection (with a socket interface)

        This function can be called to reconnect a closed connection.

        Returns the AioProtocol instance (used for handling incoming
        IRC data) and the transport instance (used for handling
        outgoing data).
        """
        if self.connected:
            self.disconnect("Changing servers")

        self.buffer = self.buffer_class()
        self.handlers = {}
        self.real_server_name = ""
        self.real_nickname = nickname
        self.server = server
        self.port = port
        self.server_address = (server, port)
        self.nickname = nickname
        self.username = username or nickname
        self.ircname = ircname or nickname
        self.password = password
        self.connect_factory = connect_factory

        protocol_instance = self.protocol_class(self, self.reactor.loop)
        connection = self.connect_factory(protocol_instance, self.server_address)
>       transport, protocol = await connection
E       ValueError: not enough values to unpack (expected 2, got 0)

irc/client_aio.py:158: ValueError
======================================================================================= 1 failed, 32 passed in 0.81 seconds =======================================================================================
jaraco commented 4 years ago

Hmm. That test passed as recently as a month ago. But it is failing for me locally on macOS. So I suspect either Python 3.8.1 is implicated or maybe macOS. Giving the timing of this bug report, I'm guessing something changed in Python 3.8.1 (released 2019-12-18).

@MattBroach Do you have any insight into the issue?

jaraco commented 4 years ago

I've marked the test as xfail until we can determine the cause. To test, run tox -- --runxfail -k test_client_aio.

MattBroach commented 4 years ago

Sorry for not looking into this sooner. I don't have any insight off the top of head, but given how unstable the asyncio interface has been, it wouldn't surprise me if something were changed in the most recently release. I'll try to find some time in the next week to do some digging and see what the issue is.