alengwenus / pypck

Asynchronous LCN-PCK library written in Python
MIT License
8 stars 4 forks source link

Test failures with Python 3.11 #105

Closed fabaff closed 1 year ago

fabaff commented 1 year ago

Tests are failing with Python 3.11

============================= test session starts ==============================
platform linux -- Python 3.11.3, pytest-7.2.1, pluggy-1.0.0
rootdir: /build/source, configfile: tox.ini
plugins: asyncio-0.20.3, timeout-2.1.0
asyncio: mode=Mode.AUTO
collected 1022 items                                                           

tests/test_commands.py ................................................. [  4%]
........................................................................ [ 11%]
........................................................................ [ 18%]
........................................................................ [ 25%]
........................................................................ [ 32%]
........................................................................ [ 40%]
........................................................................ [ 47%]
.................                                                        [ 48%]
tests/test_connection.py .FFFFFFFFFFFFFFF.EFFFFFFF                       [ 51%]
tests/test_dyn_text.py .E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E.E [ 53%]
.E.E.E.E.E.E                                                             [ 54%]
tests/test_messages.py ..........................................        [ 58%]
tests/test_vars.py ..................................................... [ 63%]
........................................................................ [ 70%]
........................................................................ [ 77%]
........................................................................ [ 84%]
........................................................................ [ 91%]
...................................................................      [ 98%]
tests/messages/test_input_flow.py ..E                                    [ 98%]
tests/messages/test_output_status.py .........FE                         [ 99%]
tests/messages/test_send_command_host.py ......FE                        [100%]

==================================== ERRORS ====================================
______________ ERROR at teardown of test_add_address_connections _______________

    def finalizer() -> None:
        """Yield again, to finalize."""

        async def async_finalizer() -> None:
            try:
                await gen_obj.__anext__()
            except StopAsyncIteration:
                pass
            else:
                msg = "Async generator fixture didn't stop."
                msg += "Yield only once."
                raise ValueError(msg)

>       event_loop.run_until_complete(async_finalizer())

/nix/store/2p1i7axac88r59c19hxb4skizx6sfcjs-python3.11-pytest-asyncio-0.20.3/lib/python3.11/site-packages/pytest_asyncio/plugin.py:297: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/nix/store/r7wqbdnn0af1s1p23n18pxf70crqqakg-python3-3.11.3/lib/python3.11/asyncio/base_events.py:653: in run_until_complete
    return future.result()
/nix/store/2p1i7axac88r59c19hxb4skizx6sfcjs-python3.11-pytest-asyncio-0.20.3/lib/python3.11/site-packages/pytest_asyncio/plugin.py:289: in async_finalizer
    await gen_obj.__anext__()
tests/conftest.py:77: in pypck_client
    await pcm.async_close()
pypck/connection.py:354: in async_close
    await self.cancel_requests()
pypck/connection.py:650: in cancel_requests
    await asyncio.wait(cancel_coros)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

fs = {<coroutine object ModuleConnection.cancel_requests at 0x7ffff5a61b40>}

    async def wait(fs, *, timeout=None, return_when=ALL_COMPLETED):
        """Wait for the Futures or Tasks given by fs to complete.

        The fs iterable must not be empty.

        Coroutines will be wrapped in Tasks.

        Returns two sets of Future: (done, pending).

        Usage:

            done, pending = await asyncio.wait(fs)

        Note: This does not raise TimeoutError! Futures that aren't done
        when the timeout occurs are returned in the second set.
        """
        if futures.isfuture(fs) or coroutines.iscoroutine(fs):
            raise TypeError(f"expect a list of futures, not {type(fs).__name__}")
        if not fs:
            raise ValueError('Set of Tasks/Futures is empty.')
        if return_when not in (FIRST_COMPLETED, FIRST_EXCEPTION, ALL_COMPLETED):
            raise ValueError(f'Invalid return_when value: {return_when}')

        fs = set(fs)

        if any(coroutines.iscoroutine(f) for f in fs):
>           raise TypeError("Passing coroutines is forbidden, use tasks explicitly.")
E           TypeError: Passing coroutines is forbidden, use tasks explicitly.
[...]
fs = {<Future pending>, <coroutine object PchkConnection.async_connect at 0x7ffff5a1dfc0>, <Future pending>}

    async def wait(fs, *, timeout=None, return_when=ALL_COMPLETED):
        """Wait for the Futures or Tasks given by fs to complete.

        The fs iterable must not be empty.

        Coroutines will be wrapped in Tasks.

        Returns two sets of Future: (done, pending).

        Usage:

            done, pending = await asyncio.wait(fs)

        Note: This does not raise TimeoutError! Futures that aren't done
        when the timeout occurs are returned in the second set.
        """
        if futures.isfuture(fs) or coroutines.iscoroutine(fs):
            raise TypeError(f"expect a list of futures, not {type(fs).__name__}")
        if not fs:
            raise ValueError('Set of Tasks/Futures is empty.')
        if return_when not in (FIRST_COMPLETED, FIRST_EXCEPTION, ALL_COMPLETED):
            raise ValueError(f'Invalid return_when value: {return_when}')

        fs = set(fs)

        if any(coroutines.iscoroutine(f) for f in fs):
>           raise TypeError("Passing coroutines is forbidden, use tasks explicitly.")
E           TypeError: Passing coroutines is forbidden, use tasks explicitly.

/nix/store/r7wqbdnn0af1s1p23n18pxf70crqqakg-python3-3.11.3/lib/python3.11/asyncio/tasks.py:415: TypeError
=============================== warnings summary ===============================
tests/test_dyn_text.py::test_dyn_text[1234567812\u20ac34567-parts30]
  /nix/store/r7wqbdnn0af1s1p23n18pxf70crqqakg-python3-3.11.3/lib/python3.11/unittest/mock.py:2124: RuntimeWarning: coroutine 'ModuleConnection.cancel_requests' was never awaited
    setattr(_type, entry, MagicProxy(entry, self))
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED tests/test_connection.py::test_authenticate - TypeError: Passing coroutines is forbidden, use tasks explicitly.
FAILED tests/test_connection.py::test_port_error - TypeError: Passing coroutines is forbidden, use tasks explicitly.
FAILED tests/test_connection.py::test_authentication_error - TypeError: Passing coroutines is forbidden, use tasks explicitly.
FAILED tests/test_connection.py::test_license_error - TypeError: Passing coroutines is forbidden, use tasks explicitly.
FAILED tests/test_connection.py::test_timeout_error - TypeError: Passing coroutines is forbidden, use tasks explicitly.
FAILED tests/test_connection.py::test_lcn_connected - TypeError: Passing coroutines is forbidden, use tasks explicitly.
FAILED tests/test_connection.py::test_lcn_disconnected - TypeError: Passing coroutines is forbidden, use tasks explicitly.
FAILED tests/test_connection.py::test_connection_lost - TypeError: Passing coroutines is forbidden, use tasks explicitly.
FAILED tests/test_connection.py::test_multiple_connections - TypeError: Passing coroutines is forbidden, use tasks explicitly.
FAILED tests/test_connection.py::test_segment_coupler_search - TypeError: Passing coroutines is forbidden, use tasks explicitly.
FAILED tests/test_connection.py::test_segment_coupler_response - TypeError: Passing coroutines is forbidden, use tasks explicitly.
FAILED tests/test_connection.py::test_module_scan - TypeError: Passing coroutines is forbidden, use tasks explicitly.
FAILED tests/test_connection.py::test_module_sn_response - TypeError: Passing coroutines is forbidden, use tasks explicitly.
FAILED tests/test_connection.py::test_send_command_to_server - TypeError: Passing coroutines is forbidden, use tasks explicitly.
FAILED tests/test_connection.py::test_ping - TypeError: Passing coroutines is forbidden, use tasks explicitly.
FAILED tests/test_connection.py::test_add_address_connections_by_message - TypeError: Passing coroutines is forbidden, use tasks explicitly.
FAILED tests/test_connection.py::test_groups_static_membership_discovery - TypeError: Passing coroutines is forbidden, use tasks explicitly.
FAILED tests/test_connection.py::test_groups_dynamic_membership_discovery - TypeError: Passing coroutines is forbidden, use tasks explicitly.
FAILED tests/test_connection.py::test_groups_membership_discovery - TypeError: Passing coroutines is forbidden, use tasks explicitly.
FAILED tests/test_connection.py::test_multiple_serial_requests - TypeError: Passing coroutines is forbidden, use tasks explicitly.
FAILED tests/test_connection.py::test_dump_modules_no_segement_couplers - TypeError: Passing coroutines is forbidden, use tasks explicitly.
FAILED tests/test_connection.py::test_dump_modules_multi_segment - TypeError: Passing coroutines is forbidden, use tasks explicitly.
FAILED tests/messages/test_output_status.py::test_output_status - TypeError: Passing coroutines is forbidden, use tasks explicitly.
FAILED tests/messages/test_send_command_host.py::test_send_command_host - TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR tests/test_connection.py::test_add_address_connections - TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR tests/test_dyn_text.py::test_dyn_text[-parts0] - TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR tests/test_dyn_text.py::test_dyn_text[a-parts1] - TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR tests/test_dyn_text.py::test_dyn_text[aaaaaaa-parts2] - TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR tests/test_dyn_text.py::test_dyn_text[aaaaaaaaaaa-parts3] - TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR tests/test_dyn_text.py::test_dyn_text[aaaaaaaaaaaa-parts4] - TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR tests/test_dyn_text.py::test_dyn_text[aaaaaaaaaaaaa-parts5] - TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR tests/test_dyn_text.py::test_dyn_text[aaaaaaaaaaaaaaaaaaa-parts6] - TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR tests/test_dyn_text.py::test_dyn_text[aaaaaaaaaaaaaaaaaaaaaaa-parts7] - TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR tests/test_dyn_text.py::test_dyn_text[aaaaaaaaaaaaaaaaaaaaaaaa-parts8] - TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR tests/test_dyn_text.py::test_dyn_text[aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-parts9] - TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR tests/test_dyn_text.py::test_dyn_text[aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-parts10] - TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR tests/test_dyn_text.py::test_dyn_text[aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-parts11] - TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR tests/test_dyn_text.py::test_dyn_text[aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-parts12] - TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR tests/test_dyn_text.py::test_dyn_text[\xfc-parts13] - TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR tests/test_dyn_text.py::test_dyn_text[\xfc\xfc\xfc\xfc\xfc-parts14] - TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR tests/test_dyn_text.py::test_dyn_text[\xfc\xfc\xfc\xfc\xfc\xfc-parts15] - TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR tests/test_dyn_text.py::test_dyn_text[\xfc\xfc\xfc\xfc\xfc\xfc\xfc-parts16] - TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR tests/test_dyn_text.py::test_dyn_text[\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc-parts17] - TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR tests/test_dyn_text.py::test_dyn_text[\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc-parts18] - TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR tests/test_dyn_text.py::test_dyn_text[\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc-parts19] - TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR tests/test_dyn_text.py::test_dyn_text[\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc-parts20] - TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR tests/test_dyn_text.py::test_dyn_text[\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc-parts21] - TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR tests/test_dyn_text.py::test_dyn_text[\u20ac-parts22] - TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR tests/test_dyn_text.py::test_dyn_text[\u20ac\u20ac\u20ac\u20ac-parts23] - TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR tests/test_dyn_text.py::test_dyn_text[\u20ac\u20ac\u20ac\u20ac\u20ac-parts24] - TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR tests/test_dyn_text.py::test_dyn_text[\u20ac\u20ac\u20ac\u20ac\u20ac\u20ac\u20ac\u20ac-parts25] - TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR tests/test_dyn_text.py::test_dyn_text[\u20ac\u20ac\u20ac\u20ac\u20ac\u20ac\u20ac\u20ac\u20ac\u20ac\u20ac\u20ac\u20ac\u20ac\u20ac\u20ac\u20ac-parts26] - TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR tests/test_dyn_text.py::test_dyn_text[\u20ac\u20ac\u20ac\u20ac\u20ac\u20ac\u20ac\u20ac\u20ac\u20ac\u20ac\u20ac\u20ac\u20ac\u20ac\u20ac\u20ac\u20ac\u20ac\u20ac-parts27] - TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR tests/test_dyn_text.py::test_dyn_text[12345678123\xfc4567-parts28] - TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR tests/test_dyn_text.py::test_dyn_text[12345678123\u20ac4567-parts29] - TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR tests/test_dyn_text.py::test_dyn_text[1234567812\u20ac34567-parts30] - TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR tests/messages/test_input_flow.py::test_physical_to_logical_segment_id - TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR tests/messages/test_output_status.py::test_output_status - TypeError: Passing coroutines is forbidden, use tasks explicitly.
ERROR tests/messages/test_send_command_host.py::test_send_command_host - TypeError: Passing coroutines is forbidden, use tasks explicitly.
============= 24 failed, 998 passed, 1 warning, 35 errors in 4.31s =============
Task was destroyed but it is pending!
task: <Task pending name='Task-280' coro=<ModuleConnection.request_serials() running at /build/source/pypck/module.py:997> wait_for=<Future pending cb=[Task.task_wakeup()]> cb=[TaskRegistry.remove_task()]>
sys:1: RuntimeWarning: coroutine 'ModuleConnection.cancel_requests' was never awaited
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
sys:1: RuntimeWarning: coroutine 'PchkConnection.async_connect' was never awaited
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Task was destroyed but it is pending!
alengwenus commented 1 year ago

Should be fixed with 0.7.17