diff options
author | Seth Nickell <seth@gnome.org> | 2004-05-30 06:21:00 +0000 |
---|---|---|
committer | Seth Nickell <seth@gnome.org> | 2004-05-30 06:21:00 +0000 |
commit | 8a10d91cc0b6f75c07e69c4663b8aea4e6096be2 (patch) | |
tree | bd1f6d793ae83c5b9fc4813e02e0061df3d5ebd7 /python/tests | |
parent | 26c937cb302506c0f4dd96e2a1dd98535f167696 (diff) |
2004-05-30 Seth Nickell <seth@gnome.org>
* python/dbus_bindings.pyx.in:
* python/tests/test-client.py:
Add some more tests and fix errors that crop up.
Unfortunately, currently it seems like marshalling
and unmarshalling of lists is completely broken :-(
Diffstat (limited to 'python/tests')
-rw-r--r-- | python/tests/test-client.py | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/python/tests/test-client.py b/python/tests/test-client.py index d12ee2aa..092ee43b 100644 --- a/python/tests/test-client.py +++ b/python/tests/test-client.py @@ -1,20 +1,37 @@ import dbus import dbus_bindings +def ensure_same(expected, received): + if type(received) != type(expected): + raise Exception ("Sending %s, expected echo of type %s, but got %s" % (expected, type(expected), type(received))) -def TestEcho(value, should_be_equal = True): + if received.__class__ != expected.__class__: + raise Exception ("Sending %s, expected echo to be of class %s, but got %s" % (expected, expected.__class__, received.__class__)) + + if received != expected: + raise Exception("Sending %s, expected echo to be the same, but was %s" % (expected, received)) + +def TestEcho(value): global remote_object echoed = remote_object.Echo(value) - if type(echoed) != type(value): - raise Exception ("Sending %s, expected echo of type %s, but got %s" % (value, type(value), type(echoed))) + ensure_same(value, echoed) + +def TestEchoList(sent_list): + assert(type(sent_list) == list) + + global remote_object + + reply_list = remote_object.Echo(sent_list) - if echoed.__class__ != value.__class__: - raise Exception ("Sending %s, expected echo to be of class %s, but got %s" % (value, value.__class__, echoed.__class__)) + if type(reply_list) != list: + raise Exception ("Sending list %s, expected echo to be a list, but it was %s" % (sent_list, type(reply_list))) - if should_be_equal: - if echoed != value: - raise Exception("Sending %s, expected echo to be the same, but was %s" % (value, echoed)) + if len(reply_list) != len(sent_list): + raise Exception ("Sending list %s, expected echo of length %d, but length was %d" % (len(sent_list), len(reply_list))) + for i in range(len(sent_list)): + ensure_same(sent_list[i], reply_list[i]) + session_bus = dbus.SessionBus() remote_service = session_bus.get_service("org.designfu.Test") @@ -26,3 +43,5 @@ TestEcho(39.5) TestEcho("HelloWorld") TestEcho(dbus_bindings.ObjectPath("/test/path")) +#FIXME!!! Crashes on lists ?!? +#TestEchoList(["one", "two", "three", "four"]) |