def end_log(test_name): global base_time results = "" for (t, self, method, args, kwargs) in get_events(): results += "%s T+%f: %s::%s(%s, *%s, *%s)\n" % (time.ctime( t), t - base_time, str(self.__class__), method, self, args, kwargs) expected = None try: expected = open(test_name + ".results", "rb").read() except: print("[events] NO TEST RESULT FOUND, creating new") open(test_name + ".new_results", "wb").write(results) print(results) if expected is not None: print("[events] expected:") if expected != results: open(test_name + ".bogus_results", "wb").write(results) raise tests.TestError("test data does not match") else: print("[events] test compared ok") else: print("[events] no test data to compare with.")
def end_log(test_name): global base_time results = "" for (t, self, method, args, kwargs) in get_events(): results += "%s T+%f: %s::%s(%s, *%s, *%s)\n" % (time.ctime( t), t - base_time, str(self.__class__), method, self, args, kwargs) expected = None if fileExists(test_name + ".results"): try: f = open(test_name + ".results", "rb") expected = f.read() f.close() except: print "NO TEST RESULT FOUND, creating new" f = open(test_name + ".new_results", "wb") f.write(results) f.close() else: print "NO TEST RESULT FOUND, creating new" f = open(test_name + ".new_results", "wb") f.write(results) f.close() print results if expected is not None: print "expected:" if expected != results: f = open(test_name + ".bogus_results", "wb") f.write(results) f.close() raise tests.TestError("test data does not match") else: print "test compared ok" else: print "no test data to compare with."
def test_timer(repeat=0, timer_start=3600, timer_length=1000, sim_length=86400 * 7): import NavigationInstance at = time.time() t = NavigationInstance.instance.RecordTimer print t print "old mwt:", t.MaxWaitTime t.MaxWaitTime = 86400 * 1000 t.processed_timers = [] t.timer_list = [] # generate a timer to test import xml.etree.cElementTree import RecordTimer timer = RecordTimer.createTimer( xml.etree.cElementTree.fromstring(""" <timer begin="%d" end="%d" serviceref="1:0:1:6DD2:44D:1:C00000:0:0:0:" repeated="%d" name="Test Event Name" description="Test Event Description" afterevent="nothing" eit="56422" disabled="0" justplay="0"> </timer>""" % (at + timer_start, at + timer_start + timer_length, repeat))) t.record(timer) # run virtual environment enigma.run(sim_length) print "done." timers = t.processed_timers + t.timer_list print "start: %s" % (time.ctime(at + 10)) assert len(timers) == 1 for t in timers: print "begin=%d, end=%d, repeated=%d, state=%d" % ( t.begin - at, t.end - at, t.repeated, t.state) print "begin: %s" % (time.ctime(t.begin)) print "end: %s" % (time.ctime(t.end)) # if repeat, check if the calculated repeated time of day matches the initial time of day if repeat: t_initial = time.localtime(at + timer_start) t_repeated = time.localtime(timers[0].begin) print t_initial print t_repeated if t_initial[3:6] != t_repeated[3:6]: raise tests.TestError("repeated timer time of day does not match")