summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Laban <david.laban@collabora.co.uk>2010-12-07 19:34:56 +0000
committerDavid Laban <david.laban@collabora.co.uk>2011-01-26 17:16:32 +0000
commit63dc72f4e45d249dc7cbccf9e721dc3ec07e2dc1 (patch)
tree04ee767347cd2d38a55d03f957222bc4572bc6df
parent9eb2013202cc29017c1925bd0e1d7c1906bf209b (diff)
Hacks to allow running multiple tests per process
* Pick a random port to create the server on each run (since IListeningPort.stopListening() isn't guaranteed to have freed the port by the time it returns) * Don't install the colourer more than once * Fix the colourer to deal with "took $seconds" misc. We should probably try to consolidate these hacks with whatever gabbletest does, or maybe try to push more stuff into servicetest to make it easier to maintain, but let's wait until sofiasip has more tests before we start doing that.
-rw-r--r--tests/twisted/sofiatest.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/tests/twisted/sofiatest.py b/tests/twisted/sofiatest.py
index 94263b9..f1b1174 100644
--- a/tests/twisted/sofiatest.py
+++ b/tests/twisted/sofiatest.py
@@ -9,6 +9,8 @@ from twisted.internet import reactor
import os
import sys
+import random
+
import dbus
import dbus.glib
@@ -46,7 +48,7 @@ def prepare_test(event_func, register_cb, params=None):
'account': 'testacc@127.0.0.1',
'password': 'testpwd',
'proxy-host': '127.0.0.1',
- 'port': dbus.UInt16(9090),
+ 'port': dbus.UInt16(random.randint(9090, 9999)),
'local-ip-address': '127.0.0.1'
}
@@ -114,8 +116,8 @@ def exec_test(fun, params=None, register_cb=default_register_cb, timeout=None):
return '\x1b[32m%s\x1b[0m' % s
patterns = {
- 'handled': green,
- 'not handled': red,
+ 'handled,': green,
+ 'not hand': red,
}
class Colourer:
@@ -124,8 +126,11 @@ def exec_test(fun, params=None, register_cb=default_register_cb, timeout=None):
self.patterns = patterns
def write(self, s):
- f = self.patterns.get(s, lambda x: x)
+ f = self.patterns.get(s[:len('handled,')], lambda x: x)
self.fh.write(f(s))
+
+ def isatty(self):
+ return False
sys.stdout = Colourer(sys.stdout, patterns)