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

Class TracerRun

Lib/test/test_bdb.py:417–462  ·  view source on GitHub ↗

Provide a context for running a Tracer instance with a test case.

Source from the content-addressed store, hash-verified

415 self.set_tuple)
416
417class TracerRun():
418 """Provide a context for running a Tracer instance with a test case."""
419
420 def __init__(self, test_case, skip=None):
421 self.test_case = test_case
422 self.dry_run = test_case.dry_run
423 self.tracer = Tracer(test_case.expect_set, skip=skip,
424 dry_run=self.dry_run, test_case=test_case.id())
425 self._original_tracer = None
426
427 def __enter__(self):
428 # test_pdb does not reset Breakpoint class attributes on exit :-(
429 reset_Breakpoint()
430 self._original_tracer = sys.gettrace()
431 return self.tracer
432
433 def __exit__(self, type_=None, value=None, traceback=None):
434 reset_Breakpoint()
435 sys.settrace(self._original_tracer)
436
437 not_empty = ''
438 if self.tracer.set_list:
439 not_empty += 'All paired tuples have not been processed, '
440 not_empty += ('the last one was number %d\n' %
441 self.tracer.expect_set_no)
442 not_empty += repr(self.tracer.set_list)
443
444 # Make a BdbNotExpectedError a unittest failure.
445 if type_ is not None and issubclass(BdbNotExpectedError, type_):
446 if isinstance(value, BaseException) and value.args:
447 err_msg = value.args[0]
448 if not_empty:
449 err_msg += '\n' + not_empty
450 if self.dry_run:
451 print(err_msg)
452 return True
453 else:
454 self.test_case.fail(err_msg)
455 else:
456 assert False, 'BdbNotExpectedError with empty args'
457
458 if not_empty:
459 if self.dry_run:
460 print(not_empty)
461 else:
462 self.test_case.fail(not_empty)
463
464def run_test(modules, set_list, skip=None):
465 """Run a test and print the dry-run results.

Callers 15

run_testFunction · 0.85
test_stepMethod · 0.85
test_stepinstrMethod · 0.85
test_nextMethod · 0.85
test_next_over_importMethod · 0.85
test_returnMethod · 0.85
test_untilMethod · 0.85

Calls

no outgoing calls

Tested by 15

run_testFunction · 0.68
test_stepMethod · 0.68
test_stepinstrMethod · 0.68
test_nextMethod · 0.68
test_next_over_importMethod · 0.68
test_returnMethod · 0.68
test_untilMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…