dbus/python/tests test-client.py,1.1,1.2

Seth Nickell seth at pdx.freedesktop.org
Sat May 29 23:21:02 PDT 2004


Update of /cvs/dbus/dbus/python/tests
In directory pdx:/tmp/cvs-serv15945/python/tests

Modified Files:
	test-client.py 
Log Message:
2004-05-30  Seth Nickell  <seth at 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 :-(


Index: test-client.py
===================================================================
RCS file: /cvs/dbus/dbus/python/tests/test-client.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- a/test-client.py	30 May 2004 05:30:09 -0000	1.1
+++ b/test-client.py	30 May 2004 06:21:00 -0000	1.2
@@ -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)
 
-    if echoed.__class__ != value.__class__:
-        raise Exception ("Sending %s, expected echo to be of class %s, but got %s" % (value, value.__class__, echoed.__class__))
+def TestEchoList(sent_list):
+    assert(type(sent_list) == list)
 
-    if should_be_equal:
-        if echoed != value:
-            raise Exception("Sending %s, expected echo to be the same, but was %s" % (value, echoed))
+    global remote_object
+
+    reply_list = remote_object.Echo(sent_list)
+
+    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 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("HelloWorld")
 TestEcho(dbus_bindings.ObjectPath("/test/path"))
 
+#FIXME!!! Crashes on lists ?!?
+#TestEchoList(["one", "two", "three", "four"])




More information about the dbus-commit mailing list