[telepathy-gabble/telepathy-gabble-0.8] google-relay.py: factor out repeated code

Dafydd Harries dafydd.harries at collabora.co.uk
Mon Sep 21 07:22:00 PDT 2009


---
 tests/twisted/jingle/google-relay.py |   37 +++++++++++++--------------------
 1 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/tests/twisted/jingle/google-relay.py b/tests/twisted/jingle/google-relay.py
index 7ab7f22..d922e8c 100644
--- a/tests/twisted/jingle/google-relay.py
+++ b/tests/twisted/jingle/google-relay.py
@@ -331,26 +331,19 @@ def test_too_slow(q, bus, conn, stream, req1, req2, media_chan, too_slow):
     # Make a misc method call to check that Gabble's still alive.
     sync_dbus(bus, q, conn)
 
+def exec_relay_test(incoming, too_slow=None):
+    exec_test(
+        lambda q, b, c, s:
+            test(q, b, c, s, incoming=incoming, too_slow=too_slow),
+        protocol=GoogleXmlStream)
+
 if __name__ == '__main__':
-    exec_test(lambda q, b, c, s: test(q, b, c, s, incoming=True),
-            protocol=GoogleXmlStream)
-    exec_test(lambda q, b, c, s: test(q, b, c, s, incoming=False),
-            protocol=GoogleXmlStream)
-    exec_test(lambda q, b, c, s: test(q, b, c, s, incoming=True,
-                                      too_slow=TOO_SLOW_CLOSE),
-            protocol=GoogleXmlStream)
-    exec_test(lambda q, b, c, s: test(q, b, c, s, incoming=False,
-                                      too_slow=TOO_SLOW_CLOSE),
-            protocol=GoogleXmlStream)
-    exec_test(lambda q, b, c, s: test(q, b, c, s, incoming=True,
-                                      too_slow=TOO_SLOW_REMOVE_SELF),
-            protocol=GoogleXmlStream)
-    exec_test(lambda q, b, c, s: test(q, b, c, s, incoming=False,
-                                      too_slow=TOO_SLOW_REMOVE_SELF),
-            protocol=GoogleXmlStream)
-    exec_test(lambda q, b, c, s: test(q, b, c, s, incoming=True,
-                                      too_slow=TOO_SLOW_DISCONNECT),
-            protocol=GoogleXmlStream)
-    exec_test(lambda q, b, c, s: test(q, b, c, s, incoming=False,
-                                      too_slow=TOO_SLOW_DISCONNECT),
-            protocol=GoogleXmlStream)
+    exec_relay_test(True)
+    exec_relay_test(False)
+    exec_relay_test(True,  TOO_SLOW_CLOSE)
+    exec_relay_test(False, TOO_SLOW_CLOSE)
+    exec_relay_test(True,  TOO_SLOW_REMOVE_SELF)
+    exec_relay_test(False, TOO_SLOW_REMOVE_SELF)
+    exec_relay_test(True,  TOO_SLOW_DISCONNECT)
+    exec_relay_test(False, TOO_SLOW_DISCONNECT)
+
-- 
1.5.6.5




More information about the telepathy-commits mailing list