altdesktop / python-dbus-next

🚌 The next great DBus library for Python with asyncio support
https://python-dbus-next.readthedocs.io/en/latest/
MIT License
187 stars 58 forks source link

test/test_fd_passing.py::test_sending_file_descriptor_low_level AssertionError: assert ['The name :1...ervice files'] == ['got it'] #161

Open ncopa opened 3 months ago

ncopa commented 3 months ago

Test fails with python 3.12:

================================================================ FAILURES ================================================================
_________________________________________________ test_sending_file_descriptor_low_level _________________________________________________

    @pytest.mark.asyncio                                             
    async def test_sending_file_descriptor_low_level():
        bus1 = await MessageBus(negotiate_unix_fd=True).connect()
        bus2 = await MessageBus(negotiate_unix_fd=True).connect()

        fd_before = open_file()                                      
        fd_after = None                                              

        msg = Message(destination=bus1.unique_name,
                      path='/org/test/path',
                      interface='org.test.iface',
                      member='SomeMember',
                      body=[0],
                      signature='h',                                 
                      unix_fds=[fd_before])                                                                                               

        def message_handler(sent): 
            nonlocal fd_after
            if sent.sender == bus2.unique_name and sent.serial == msg.serial:
                assert sent.path == msg.path
                assert sent.serial == msg.serial
                assert sent.interface == msg.interface
                assert sent.member == msg.member
                assert sent.body == [0]
                assert len(sent.unix_fds) == 1
                fd_after = sent.unix_fds[0]
                bus1.send(Message.new_method_return(sent, 's', ['got it']))
                bus1.remove_message_handler(message_handler)
                return True

        bus1.add_message_handler(message_handler)

        reply = await bus2.call(msg)
>       assert reply.body == ['got it']
E       AssertionError: assert ['The name :1...ervice files'] == ['got it']
E         
E         At index 0 diff: 'The name :1.46 was not provided by any .service files' != 'got it'
E         Use -v to get more diff

test/test_fd_passing.py:103: AssertionError
----------------------------------------------------------- Captured log call ------------------------------------------------------------
ERROR    asyncio:base_events.py:1819 Future exception was never retrieved
future: <Future finished exception=OSError(9, 'Bad file descriptor')> 
Traceback (most recent call last): 
  File "/home/ncopa/aports/community/py3-dbus-next/src/python-dbus-next-0.2.3/test/test_disconnect.py", line 56, in test_unexpected_discon
nect
    await bus.wait_for_disconnect()
  File "/home/ncopa/aports/community/py3-dbus-next/src/python-dbus-next-0.2.3/dbus_next/aio/message_bus.py", line 342, in wait_for_disconn
ect
    return await self._disconnect_future
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ncopa/aports/community/py3-dbus-next/src/python-dbus-next-0.2.3/dbus_next/aio/message_bus.py", line 63, in write_callback
    self.offset += self.sock.send(self.buf[self.offset:])
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 9] Bad file descriptor
======================================================== short test summary info =========================================================
FAILED test/test_fd_passing.py::test_sending_file_descriptor_low_level - AssertionError: assert ['The name :1...ervice files'] == ['got it
']
========================================= 1 failed, 73 passed, 7 skipped, 1 deselected in 0.32s ==========================================