MCPcopy Index your code
hub / github.com/python/cpython / test_main_with_time_unit

Method test_main_with_time_unit

Lib/test/test_timeit.py:335–353  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

333 """))
334
335 def test_main_with_time_unit(self):
336 unit_sec = self.run_main(seconds_per_increment=0.003,
337 switches=['-u', 'sec'])
338 self.assertEqual(unit_sec,
339 "100 loops, best of 5: 0.003 sec per loop\n")
340 unit_msec = self.run_main(seconds_per_increment=0.003,
341 switches=['-u', 'msec'])
342 self.assertEqual(unit_msec,
343 "100 loops, best of 5: 3 msec per loop\n")
344 unit_usec = self.run_main(seconds_per_increment=0.003,
345 switches=['-u', 'usec'])
346 self.assertEqual(unit_usec,
347 "100 loops, best of 5: 3e+03 usec per loop\n")
348 # Test invalid unit input
349 with captured_stderr() as error_stringio:
350 invalid = self.run_main(seconds_per_increment=0.003,
351 switches=['-u', 'parsec'])
352 self.assertEqual(error_stringio.getvalue(),
353 "Unrecognized unit. Please select nsec, usec, msec, or sec.\n")
354
355 @force_not_colorized
356 def test_main_exception(self):

Callers

nothing calls this directly

Calls 4

run_mainMethod · 0.95
captured_stderrFunction · 0.90
assertEqualMethod · 0.45
getvalueMethod · 0.45

Tested by

no test coverage detected