[Telepathy-commits] [telepathy-idle/master] call Disconnect() asynchronously to prevent false test failures

Jonathon Jongsma jonathon.jongsma at collabora.co.uk
Fri Feb 13 17:43:16 PST 2009


previously, the -success and the -success-ssl tests were failing because they
didn't get a dbus method return from the Disconnect() method.  I thought that
this was a problem with idle not returning the response, but it turns out it was
caused by the fact that the test called Disconnect() synchronously.  So while
the test was waiting for the dbus return, the QUIT handler could not run, so the
connection was not getting closed.  Apparently idle waits for the connection to
be closed before sending the dbus method return.

When I change the Disconnect() call to be async, the test irc client is allowed
to run and the tests now pass.
---
 tests/twisted/connect/connect-success-ssl.py |    9 ++++++---
 tests/twisted/connect/connect-success.py     |    9 ++++++---
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/tests/twisted/connect/connect-success-ssl.py b/tests/twisted/connect/connect-success-ssl.py
index 5fba542..3cf04e8 100644
--- a/tests/twisted/connect/connect-success-ssl.py
+++ b/tests/twisted/connect/connect-success-ssl.py
@@ -5,7 +5,7 @@ Test connecting to a SSL server.
 
 import dbus
 from idletest import exec_test, SSLIRCServer
-from servicetest import EventPattern
+from servicetest import EventPattern, call_async
 
 def test(q, bus, conn, stream):
     conn.Connect()
@@ -15,8 +15,11 @@ def test(q, bus, conn, stream):
     q.expect('dbus-signal', signal='SelfHandleChanged',
         args=[1L])
     q.expect('dbus-signal', signal='StatusChanged', args=[0, 1])
-    conn.Disconnect()
-    q.expect('dbus-signal', signal='StatusChanged', args=[2, 1])
+    call_async(q, conn, 'Disconnect')
+    q.expect_many(
+            EventPattern('dbus-signal', signal='StatusChanged', args=[2, 1]),
+            EventPattern('irc-disconnected'),
+            EventPattern('dbus-return', method='Disconnect'))
     return True
 
 if __name__ == '__main__':
diff --git a/tests/twisted/connect/connect-success.py b/tests/twisted/connect/connect-success.py
index 70f4f62..9ef189b 100644
--- a/tests/twisted/connect/connect-success.py
+++ b/tests/twisted/connect/connect-success.py
@@ -4,7 +4,7 @@ Test connecting to a server.
 """
 
 from idletest import exec_test
-from servicetest import EventPattern
+from servicetest import EventPattern, call_async
 
 def test(q, bus, conn, stream):
     conn.Connect()
@@ -14,8 +14,11 @@ def test(q, bus, conn, stream):
     q.expect('dbus-signal', signal='SelfHandleChanged',
         args=[1L])
     q.expect('dbus-signal', signal='StatusChanged', args=[0, 1])
-    conn.Disconnect()
-    q.expect('dbus-signal', signal='StatusChanged', args=[2, 1])
+    call_async(q, conn, 'Disconnect')
+    q.expect_many(
+            EventPattern('dbus-signal', signal='StatusChanged', args=[2, 1]),
+            EventPattern('irc-disconnected'),
+            EventPattern('dbus-return', method='Disconnect'))
     return True
 
 if __name__ == '__main__':
-- 
1.5.6.5




More information about the telepathy-commits mailing list