[Telepathy-commits] [telepathy-gabble/master] _socks5_expect_connection: wait for the connected and expected event at the same time

Guillaume Desmottes guillaume.desmottes at collabora.co.uk
Thu Feb 26 02:49:48 PST 2009


---
 tests/twisted/bytestream.py |   22 ++++++++++++----------
 1 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/tests/twisted/bytestream.py b/tests/twisted/bytestream.py
index d25bb9e..411f994 100644
--- a/tests/twisted/bytestream.py
+++ b/tests/twisted/bytestream.py
@@ -7,7 +7,7 @@ from twisted.words.protocols.jabber.client import IQ
 from twisted.words.xish import xpath, domish
 from twisted.internet.error import CannotListenError
 
-from servicetest import Event
+from servicetest import Event, EventPattern
 from gabbletest import acknowledge_iq, sync_stream
 import ns
 
@@ -147,12 +147,21 @@ class BytestreamS5B(Bytestream):
         # FIXME: This is wrong. Change once SOCKS5 is fixed
         self.transport.write('\x05\x00') #version 5, ok
 
-    def _socks5_expect_connection(self):
+    def _socks5_expect_connection(self, expected):
+        if expected is not None:
+            event, _ = self.q.expect_many(expected,
+                EventPattern('s5b-connected'))
+        else:
+            event = None
+            self.q.expect('s5b-connected')
+
         self._wait_auth_request()
         self._send_auth_reply()
         self._wait_connect_cmd()
         self._send_connect_reply()
 
+        return event
+
     def _listen_socks5(self):
         for port in range(5000,5100):
             try:
@@ -169,14 +178,7 @@ class BytestreamS5B(Bytestream):
 
         self._send_socks5_init([(self.initiator, '127.0.0.1', port)])
 
-        if expected is not None:
-            event = self.q.expect_many(expected)[0]
-        else:
-            event = None
-
-        self._socks5_expect_connection()
-
-        return event
+        return self._socks5_expect_connection(expected)
 
     def send_data(self, data):
         self.transport.write(data)
-- 
1.5.6.5




More information about the telepathy-commits mailing list