def test_local_children(self): children = [ 'year', 'day', 'month', 'hour', 'minute', 'weekday', 'second', 'milliseconds' ] t = Time() t.configure({'name': 'time', 'parent': None}) l = t.get_child('local') for c in children: if c not in l.children_names(): msg = 'Child "' + str(c) + '" was not found in Local children ' for x in l.children_names(): msg += str(x) + ',' msg = msg[:-1] + '\n' msg = msg + 'Child "' + str( c) + '" should be an inherent child of Local' self.fail(msg) if len(children) != len(l.children_names()): msg = 'Local has a different amount of inherent children then I know about!\n' msg += 'I think it should have only:\n' for c in children: msg += c + '\n' msg += '\nLocal has Children:\n' for c in l.children.names(): msg += c + '\n' self.fail(msg)
def check_attribute(self,child,attribute): t = Time() t.configure({'name':'time','parent':None}) c = t.get_child(child) c_value = c.get_child(attribute).get() if attribute != 'milliseconds': attributes = {'year':0,'month':1, 'day':2,'hour':3, 'weekday':6,'minute':4, 'second':5} if child == 'UTC': tuple = time.gmtime() elif child == 'local': tuple = time.localtime() real_value = tuple[attributes[attribute]] if c_value != real_value: self.fail(child + ' "' + attribute +'" is not correct\n' + child + ' ' + attribute + ' came back as: ' + str(c_value) + '\n' + 'Correct value: ' + str(real_value)) else: t = time.time() real_value = (t - int(t)) *1000 if c_value < (real_value +.5) and c_value > (real_value -.5): pass else: self.fail(child + ' "' + attribute +'" is not correct\n' + child + ' ' + attribute + ' came back as: ' + str(c_value) + '\n' + 'Correct value: ' + str(real_value))
def test_UTC_children(self): children = ['year','month','day','hour','minute','weekday','second','milliseconds'] t = Time() t.configure({'name':'time','parent':None}) u = t.get_child('UTC') for c in children: if c not in u.children_names(): msg = 'Child "' + str(c) + '" was not found in UTC children ' for x in u.children_names(): msg += str(x) + ',' msg = msg[:-1] + '\n' msg = msg + 'Child "' + str(c) + '" should be an inherent child of UTC' self.fail(msg) if len(children) != len(u.children_names()): msg = 'UTC has a different amount of inherent children then I know about!\n' msg += 'I think it should have only:\n' for c in children: msg += c + '\n' msg += '\nUTC has Children:\n' for c in u.children_names(): msg += c + '\n' self.fail(msg)
def check_attribute(self, child, attribute): t = Time() t.configure({'name': 'time', 'parent': None}) c = t.get_child(child) c_value = c.get_child(attribute).get() if attribute != 'milliseconds': attributes = { 'year': 0, 'month': 1, 'day': 2, 'hour': 3, 'weekday': 6, 'minute': 4, 'second': 5 } if child == 'UTC': tuple = time.gmtime() elif child == 'local': tuple = time.localtime() real_value = tuple[attributes[attribute]] if c_value != real_value: self.fail(child + ' "' + attribute + '" is not correct\n' + child + ' ' + attribute + ' came back as: ' + str(c_value) + '\n' + 'Correct value: ' + str(real_value)) else: t = time.time() real_value = (t - int(t)) * 1000 if c_value < (real_value + .5) and c_value > (real_value - .5): pass else: self.fail(child + ' "' + attribute + '" is not correct\n' + child + ' ' + attribute + ' came back as: ' + str(c_value) + '\n' + 'Correct value: ' + str(real_value))