Пример #1
0
 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
Пример #2
0
 def test_timer_report_no_stdout(self, name, capsys):
     logger.start_timer(name)
     _ = logger.report_timer(name)
     test_output = capsys.readouterr().out
     assert test_output == ''
Пример #3
0
 def test_timer_report_value(self, name):
     logger.start_timer(name)
     time.sleep(0.01)
     result = logger.report_timer(name)
     assert self.convert_timestring_to_seconds(result) >= 0.01
Пример #4
0
 def test_timer_report_return_type(self, name):
     logger.start_timer(name)
     result = logger.report_timer(name)
     assert isinstance(result, str)
     assert len(result) > 0
Пример #5
0
 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
Пример #6
0
 def test_timer_run_time_running(self, name):
     logger.start_timer(name)
     time.sleep(0.01)
     assert time.perf_counter() - logger._timers[name].start_time >= 0.01
Пример #7
0
 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()
Пример #8
0
 def test_timer_stop_time(self, name):
     logger.start_timer(name)
     time.sleep(0.01)
     logger.stop_timer(name)
     assert logger._timers[name].stop_time <= time.perf_counter()
Пример #9
0
 def test_timer_creation_on_start(self, name):
     logger.start_timer(name)
     assert name in logger._timers