def test_timer_get_non_existent(self, name): if name == self.default_timer: condition = does_not_raise() else: condition = pytest.raises(IndexError) with condition: logger.get_timer(name)
def test_timer_get_run_time_stopped(self, name): logger.start_timer(name) time.sleep(0.01) logger.stop_timer(name) timer = logger.get_timer(name) time.sleep(0.05) assert timer.stop_time - timer.start_time >= 0.01 assert timer.stop_time - timer.start_time < 0.05
def test_timer_get_added(self, name): if name != self.default_timer: timer = logger.Timer() logger.add_timer(name, timer) else: timer = logger._timers[name] result = logger.get_timer(name) assert result == timer
def test_timer_get_run_time_running(self, name): logger.start_timer(name) time.sleep(0.01) timer = logger.get_timer(name) assert time.perf_counter() - timer.start_time >= 0.01
def test_timer_get_stop_time(self, name): logger.start_timer(name) time.sleep(0.01) logger.stop_timer(name) timer = logger.get_timer(name) assert timer.stop_time <= time.perf_counter()
def test_timer_get_created_return_type(self, name): if name != self.default_timer: logger.add_timer(name) timer = logger.get_timer(name) assert isinstance(timer, logger.Timer)
def test_timer_get_created(self, name): if name != self.default_timer: logger.add_timer(name) timer = logger.get_timer(name) assert timer is not None
def test_timer_get_defaults_return_type(self, name): timer = logger.get_timer(name) assert isinstance(timer, logger.Timer)
def test_timer_get_defaults(self, name): timer = logger.get_timer(name) assert timer is not None