diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2007-04-24 17:45:03 +0100 |
---|---|---|
committer | Simon McVittie <smcv@carbon.pseudorandom.co.uk> | 2007-04-24 18:04:39 +0100 |
commit | ae8014c72a7d304f20d9422009f42bc48fa8f298 (patch) | |
tree | b14b2dab789246778fe150e6802f9c86fecf22e0 /test | |
parent | 705b343c205b82c93aab0f31535d1dc99a3c0265 (diff) |
Fix fd.o #10174: make it possible to return multiple values with no signature.
More specifically: when a service method with no signature synchronously
returns a tuple that is not a Struct, interpret it as a multi-valued return,
rather than as a structure.
This is a common Python idiom, and returning a struct makes little sense
anyway when D-Bus lets you return multiple values.
Returned lists are still interpreted as arrays - returning an array is
entirely sensible, and indeed likely to be common.
Async service methods are unaffected (there is no ambiguity), and it's still
possible to return a structure by returning a dbus.Struct with appropriate
contents.
https://bugs.freedesktop.org/show_bug.cgi?id=10174
Diffstat (limited to 'test')
-rwxr-xr-x | test/test-client.py | 6 | ||||
-rwxr-xr-x | test/test-service.py | 5 |
2 files changed, 11 insertions, 0 deletions
diff --git a/test/test-client.py b/test/test-client.py index 49578f7..de180ef 100755 --- a/test/test-client.py +++ b/test/test-client.py @@ -336,6 +336,12 @@ class TestDBusBindings(unittest.TestCase): ret = bus.name_has_owner('org.freedesktop.DBus.Python.TestName') self.assert_(not ret, 'deleting reference failed to release BusName org.freedesktop.DBus.Python.TestName') + def testMultipleReturnWithoutSignature(self): + # https://bugs.freedesktop.org/show_bug.cgi?id=10174 + ret = self.iface.MultipleReturnWithoutSignature() + self.assert_(not isinstance(ret, dbus.Struct), repr(ret)) + self.assertEquals(ret, ('abc', 123)) + """ Remove this for now class TestDBusPythonToGLibBindings(unittest.TestCase): def setUp(self): diff --git a/test/test-service.py b/test/test-service.py index 601ee5e..5c6fcdb 100755 --- a/test/test-service.py +++ b/test/test-service.py @@ -183,6 +183,11 @@ class TestObject(dbus.service.Object, TestInterface): def WhoAmI(self, sender): return sender + @dbus.service.method(IFACE) + def MultipleReturnWithoutSignature(self): + # https://bugs.freedesktop.org/show_bug.cgi?id=10174 + return dbus.String('abc'), dbus.Int32(123) + session_bus = dbus.SessionBus() name = dbus.service.BusName("org.freedesktop.DBus.TestSuitePythonService", bus=session_bus) object = TestObject(name) |