postlund / pyatv

A client library for Apple TV and AirPlay devices
https://pyatv.dev
MIT License
827 stars 87 forks source link

test_simple_dispatch fails on Python 3.12 #2365

Open mweinelt opened 2 months ago

mweinelt commented 2 months ago

Describe the bug

Running the test suite on Python 3.12 fails the test_simple_dispatch test.

Error log

_____________________________ test_simple_dispatch _____________________________

    async def test_simple_dispatch():
        dispatched_msg1 = None
        dispatched_msg2 = None

        async def dispatch_func1(message: bytes) -> None:
            nonlocal dispatched_msg1
            dispatched_msg1 = message

        def dispatch_func2(message: bytes) -> None:
            nonlocal dispatched_msg2
            dispatched_msg2 = message

        dispatcher = MessageDispatcher[int, bytes]()
        dispatcher.listen_to(1, dispatch_func1)
        dispatcher.listen_to(2, dispatch_func2)

        await asyncio.wait_for(asyncio.gather(*dispatcher.dispatch(1, b"123")), 5.0)
        assert dispatched_msg1 == b"123"
        assert dispatched_msg2 is None

        dispatched_msg1 = None

        await asyncio.wait_for(asyncio.gather(*dispatcher.dispatch(2, b"456")), 5.0)
        assert dispatched_msg1 is None
>       assert dispatched_msg2 == b"456"
E       AssertionError: assert None == b'456'

tests/core/test_protocol.py:163: AssertionError

How to reproduce the bug?

Run the testsuite von Python 3.12.

What is expected behavior?

It should pass, same as on Python 3.11.

Operating System

Linux

Python

Other

pyatv

0.14.5

Device

n/a

Additional context

n/a