6 def event(self, name, args, kwargs):
8 print "*EVENT*", time.time(), self, name, args, kwargs
9 recorded_events.append((time.time(), self, name, args, kwargs))
13 def wrapper(self, *args, **kwargs):
14 event(self, name, args, kwargs)
15 return f(self, *args, **kwargs)
19 global recorded_events
26 base_time = time.time()
28 def end_log(test_name):
33 for (t, self, method, args, kwargs) in get_events():
34 results += "%s T+%f: %s::%s(%s, *%s, *%s)\n" % (time.ctime(t), t - base_time, str(self.__class__), method, self, args, kwargs)
39 f = open(test_name + ".results", "rb")
43 print "NO TEST RESULT FOUND, creating new"
44 f = open(test_name + ".new_results", "wb")
48 print expected, results
50 if expected is not None:
52 if expected != results:
53 open(test_name + ".bogus_results", "wb").write(results)
54 raise tests.TestError("test data does not match")
56 print "test compared ok"
58 print "no test data to compare with."
60 def log(fnc, base_time = 0, test_name = "test", *args, **kwargs):
62 fake_time.setTime(base_time)
67 event(None, "test_completed", [], {"test_name": test_name})
68 except tests.TestError,c:
69 event(None, "test_failed", [], {"test_name": test_name, "reason": str(c)})