(self, seconds_per_increment=1.0, switches=None, timer=None)
| 238 | MAIN_DEFAULT_OUTPUT = "1 loop, best of 5: 1 sec per loop\n" |
| 239 | |
| 240 | def run_main(self, seconds_per_increment=1.0, switches=None, timer=None): |
| 241 | if timer is None: |
| 242 | timer = FakeTimer(seconds_per_increment=seconds_per_increment) |
| 243 | if switches is None: |
| 244 | args = [] |
| 245 | else: |
| 246 | args = switches[:] |
| 247 | args.append(self.fake_stmt) |
| 248 | # timeit.main() modifies sys.path, so save and restore it. |
| 249 | orig_sys_path = sys.path[:] |
| 250 | with captured_stdout() as s: |
| 251 | timeit.main(args=args, _wrap_timer=timer.wrap_timer) |
| 252 | sys.path[:] = orig_sys_path[:] |
| 253 | return s.getvalue() |
| 254 | |
| 255 | def test_main_bad_switch(self): |
| 256 | s = self.run_main(switches=['--bad-switch']) |
no test coverage detected