예제 #1
0
 def test(*args, **kwargs):
     self.__test_runtime = None
     initial_draws = len(data.draw_times)
     start = benchmark_time()
     result = self.test(*args, **kwargs)
     finish = benchmark_time()
     internal_draw_time = sum(data.draw_times[initial_draws:])
     runtime = (finish - start - internal_draw_time) * 1000
     self.__test_runtime = runtime
     if self.settings.deadline is not_set:
         if (not self.__warned_deadline and runtime >= 200):
             self.__warned_deadline = True
             note_deprecation(
                 ('Test took %.2fms to run. In future the default '
                  'deadline setting will be 200ms, which will '
                  'make this an error. You can set deadline to '
                  'an explicit value of e.g. %d to turn tests '
                  'slower than this into an error, or you can set '
                  'it to None to disable this check entirely.') % (
                      runtime,
                      ceil(runtime / 100) * 100,
                  ))
     else:
         current_deadline = self.settings.deadline
         if not is_final:
             current_deadline *= 1.25
         if runtime >= current_deadline:
             raise DeadlineExceeded(runtime, self.settings.deadline)
     return result
예제 #2
0
 def test(*args, **kwargs):
     self.__test_runtime = None
     initial_draws = len(data.draw_times)
     start = benchmark_time()
     result = self.test(*args, **kwargs)
     finish = benchmark_time()
     internal_draw_time = sum(data.draw_times[initial_draws:])
     runtime = (finish - start - internal_draw_time) * 1000
     self.__test_runtime = runtime
     current_deadline = self.settings.deadline
     if not is_final:
         current_deadline *= 1.25
     if runtime >= current_deadline:
         raise DeadlineExceeded(runtime, self.settings.deadline)
     return result
예제 #3
0
 def test(*args, **kwargs):
     self.__test_runtime = None
     initial_draws = len(data.draw_times)
     start = perf_counter()
     result = self.test(*args, **kwargs)
     finish = perf_counter()
     internal_draw_time = sum(data.draw_times[initial_draws:])
     runtime = datetime.timedelta(
         seconds=finish - start - internal_draw_time
     )
     self.__test_runtime = runtime
     current_deadline = self.settings.deadline
     if not is_final:
         current_deadline = (current_deadline // 4) * 5
     if runtime >= current_deadline:
         raise DeadlineExceeded(runtime, self.settings.deadline)
     return result
예제 #4
0
 def timed_test(*args, **kwargs):
     start = time.time()
     result = test(*args, **kwargs)
     runtime = (time.time() - start) * 1000
     if self.settings.deadline is not_set:
         if (not self.__warned_deadline and runtime >= 200):
             self.__warned_deadline = True
             note_deprecation(
                 ('Test took %.2fms to run. In future the default '
                  'deadline setting will be 200ms, which will '
                  'make this an error. You can set deadline to '
                  'an explicit value of e.g. %d to turn tests '
                  'slower than this into an error, or you can set '
                  'it to None to disable this check entirely.') % (
                      runtime,
                      ceil(runtime / 100) * 100,
                  ))
     elif runtime >= self.settings.deadline:
         raise DeadlineExceeded(
             ('Test took %.2fms, which exceeds the deadline of '
              '%.2fms') % (runtime, self.settings.deadline))
     return result