[telepathy-gabble/master] gabbletest.py: exec_test_deferred: properly handle the different state of the Connection at the end of the test

Guillaume Desmottes guillaume.desmottes at collabora.co.uk
Fri Sep 11 07:56:23 PDT 2009


---
 tests/twisted/gabbletest.py |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/tests/twisted/gabbletest.py b/tests/twisted/gabbletest.py
index f879f93..d6f850d 100644
--- a/tests/twisted/gabbletest.py
+++ b/tests/twisted/gabbletest.py
@@ -418,10 +418,19 @@ def exec_test_deferred(funs, params, protocol=None, timeout=None,
         # please ignore the POSIX behind the curtain
         d.addBoth((lambda *args: os._exit(1)))
 
+    # Does the Connection object still exist?
+    if not bus.name_has_owner(conn.object.bus_name):
+        # Connection has already been disconnected and destroyed
+        return
+
     try:
-        disconnect_conn(queue, conn, stream)
+        if conn.GetStatus() == cs.CONN_STATUS_CONNECTED:
+            # Connection is connected, properly disconnect it
+            disconnect_conn(queue, conn, stream)
+        else:
+            # Connection is not connected, call Disconnect() to destroy it
+            conn.Disconnect()
     except dbus.DBusException, e:
-        # Connection has already been disconnected
         pass
 
 def exec_tests(funs, params=None, protocol=None, timeout=None,
-- 
1.5.6.5




More information about the telepathy-commits mailing list