def test_MonotonicClock(): try: mc = MonotonicClock() t1 = mc.getTime() time.sleep(1.0) t2 = mc.getTime() startTime = mc.getLastResetTime() assert t2 > t1 assert t2 - t1 > 0.95 assert t2 - t1 < 1.05 assert startTime > 0 # Test things that 'should fail': try: x = mc.timeAtLastReset assert 1 == "MonotonicClock should not have an attribute called 'timeAtLastReset'." except Exception: pass try: x = mc.reset() assert 1 == "MonotonicClock should not have a method 'reset()'." except Exception: pass try: x = mc.add() assert 1 == "MonotonicClock should not have a method 'add()'." except Exception: pass printf(">> MonotonicClock Test: PASSED") except Exception: printf(">> MonotonicClock Test: FAILED") printExceptionDetails() printf("-------------------------------------\n")
def testMonotonicClock(): try: mc = MonotonicClock() t1=mc.getTime() time.sleep(1.0) t2=mc.getTime() startTime=mc.getLastResetTime() assert t2>t1 assert t2-t1 > 0.95 assert t2-t1 < 1.05 assert startTime > 0 # Test things that 'should fail': try: x=mc.timeAtLastReset assert 1=="MonotonicClock should not have an attribute called 'timeAtLastReset'." except Exception: pass try: x=mc.reset() assert 1=="MonotonicClock should not have a method 'reset()'." except Exception: pass try: x=mc.add() assert 1=="MonotonicClock should not have a method 'add()'." except Exception: pass printf(">> MonotonicClock Test: PASSED") except Exception: printf(">> MonotonicClock Test: FAILED") printExceptionDetails() printf("-------------------------------------\n")