@@ -354,13 +354,8 @@ def test_main_exception_fixed_reps(self):
354354 s = self .run_main (switches = ['-n1' , '1/0' ])
355355 self .assert_exc_string (error_stringio .getvalue (), 'ZeroDivisionError' )
356356
357- def autorange (self , seconds_per_increment = 1 / 1024 , callback = None ):
358- timer = FakeTimer (seconds_per_increment = seconds_per_increment )
359- t = timeit .Timer (stmt = self .fake_stmt , setup = self .fake_setup , timer = timer )
360- return t .autorange (callback )
361-
362- def autorange_with_argument (self , total_time , seconds_per_increment = 1 / 1024 ,
363- callback = None ):
357+ def autorange (self , seconds_per_increment = 1 / 1024 , callback = None ,
358+ total_time = 0.2 ):
364359 timer = FakeTimer (seconds_per_increment = seconds_per_increment )
365360 t = timeit .Timer (stmt = self .fake_stmt , setup = self .fake_setup , timer = timer )
366361 return t .autorange (callback , total_time )
@@ -370,16 +365,11 @@ def test_autorange(self):
370365 self .assertEqual (num_loops , 500 )
371366 self .assertEqual (time_taken , 500 / 1024 )
372367
373- def test_autorange_with_argument (self ):
374- num_loops , time_taken = self .autorange_with_argument (total_time = 0.6 )
368+ def test_autorange_with_total_time (self ):
369+ num_loops , time_taken = self .autorange (total_time = 0.6 )
375370 self .assertEqual (num_loops , 1000 )
376371 self .assertEqual (time_taken , 1000 / 1024 )
377372
378- def test_autorange_with_argument (self ):
379- num_loops , time_taken = self .autorange_with_argument (total_time = 0.4 )
380- self .assertEqual (num_loops , 500 )
381- self .assertEqual (time_taken , 500 / 1024 )
382-
383373 def test_autorange_second (self ):
384374 num_loops , time_taken = self .autorange (seconds_per_increment = 1.0 )
385375 self .assertEqual (num_loops , 1 )
@@ -403,11 +393,11 @@ def callback(a, b):
403393 '500 0.488\n ' )
404394 self .assertEqual (s .getvalue (), expected )
405395
406- def test_autorange_with_callback_with_argument (self ):
396+ def test_autorange_with_callback_and_total_time (self ):
407397 def callback (a , b ):
408398 print ("{} {:.3f}" .format (a , b ))
409399 with captured_stdout () as s :
410- num_loops , time_taken = self .autorange_with_argument (callback = callback ,
400+ num_loops , time_taken = self .autorange (callback = callback ,
411401 total_time = 0.6 )
412402 self .assertEqual (num_loops , 1000 )
413403 self .assertEqual (time_taken , 1000 / 1024 )
@@ -423,24 +413,6 @@ def callback(a, b):
423413 '1000 0.977\n ' )
424414 self .assertEqual (s .getvalue (), expected )
425415
426- def test_autorange_with_callback_with_argument (self ):
427- def callback (a , b ):
428- print ("{} {:.3f}" .format (a , b ))
429- with captured_stdout () as s :
430- num_loops , time_taken = self .autorange_with_argument (callback = callback ,
431- total_time = 0.4 )
432- self .assertEqual (num_loops , 500 )
433- self .assertEqual (time_taken , 500 / 1024 )
434- expected = ('1 0.001\n '
435- '2 0.002\n '
436- '5 0.005\n '
437- '10 0.010\n '
438- '20 0.020\n '
439- '50 0.049\n '
440- '100 0.098\n '
441- '200 0.195\n '
442- '500 0.488\n ' )
443- self .assertEqual (s .getvalue (), expected )
444416
445417if __name__ == '__main__' :
446418 unittest .main ()
0 commit comments