kumquat-buildroot/support/testing/tests/package/sample_python_dbus_next.py
Arnout Vandecappelle (Essensium/Mind) 1217817ac2 support/testing: sample_python_dbus_next: ignore F821 flake8 error
The dbus-next package uses the Python type annotation for dbus types. This is
not compatible with the python typing assumption that flake8 makes.

Exclude F821 from this line.

Fixes: https://gitlab.com/buildroot.org/buildroot/-/jobs/1687009829
partially:
support/testing/tests/package/sample_python_dbus_next.py:17:36: F821 undefined name 's'
support/testing/tests/package/sample_python_dbus_next.py:17:48: F821 undefined name 's'
support/testing/tests/package/sample_python_dbus_next.py:17:56: F821 undefined name 's'

Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
2021-10-18 22:30:44 +02:00

45 lines
1.2 KiB
Python

import asyncio
from dbus_next.aio import MessageBus
from dbus_next.service import ServiceInterface, method
import dbus_next.introspection as intr
from dbus_next import BusType
class SampleInterface(ServiceInterface):
def __init__(self):
super().__init__('test.interface')
@method()
def Ping(self):
pass
@method()
def ConcatStrings(self, what1: 's', what2: 's') -> 's': # noqa: F821
return what1 + what2
async def main():
bus_name = 'dbus.next.sample'
bus = await MessageBus(bus_type=BusType.SYSTEM).connect()
bus2 = await MessageBus(bus_type=BusType.SYSTEM).connect()
await bus.request_name(bus_name)
service_interface = SampleInterface()
bus.export('/test/path', service_interface)
introspection = await bus2.introspect(bus_name, '/test/path')
assert type(introspection) is intr.Node
obj = bus2.get_proxy_object(bus_name, '/test/path', introspection)
interface = obj.get_interface(service_interface.name)
result = await interface.call_ping()
assert result is None
result = await interface.call_concat_strings('hello ', 'world')
assert result == 'hello world'
asyncio.run(main())