MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_pdb_continue_with_recursive_debug

Method test_pdb_continue_with_recursive_debug

testing/test_debugging.py:659–749  ·  view source on GitHub ↗

Full coverage for do_debug without capturing. This is very similar to test_pdb_interaction_continue_recursive in general, but mocks out ``pdb.set_trace`` for providing more coverage.

(
        self, capture_arg, pytester: Pytester
    )

Source from the content-addressed store, hash-verified

657
658 @pytest.mark.parametrize("capture_arg", ("", "-s", "-p no:capture"))
659 def test_pdb_continue_with_recursive_debug(
660 self, capture_arg, pytester: Pytester
661 ) -> None:
662 """Full coverage for do_debug without capturing.
663
664 This is very similar to test_pdb_interaction_continue_recursive in general,
665 but mocks out ``pdb.set_trace`` for providing more coverage.
666 """
667 p1 = pytester.makepyfile(
668 """
669 try:
670 input = raw_input
671 except NameError:
672 pass
673
674 def set_trace():
675 __import__('pdb').set_trace()
676
677 def test_1(monkeypatch):
678 import _pytest.debugging
679
680 class pytestPDBTest(_pytest.debugging.pytestPDB):
681 @classmethod
682 def set_trace(cls, *args, **kwargs):
683 # Init PytestPdbWrapper to handle capturing.
684 _pdb = cls._init_pdb("set_trace", *args, **kwargs)
685
686 # Mock out pdb.Pdb.do_continue.
687 import pdb
688 pdb.Pdb.do_continue = lambda self, arg: None
689
690 print("===" + " SET_TRACE ===")
691 assert input() == "debug set_trace()"
692
693 # Simulate PytestPdbWrapper.do_debug
694 cls._recursive_debug += 1
695 print("ENTERING RECURSIVE DEBUGGER")
696 print("===" + " SET_TRACE_2 ===")
697
698 assert input() == "c"
699 _pdb.do_continue("")
700 print("===" + " SET_TRACE_3 ===")
701
702 # Simulate PytestPdbWrapper.do_debug
703 print("LEAVING RECURSIVE DEBUGGER")
704 cls._recursive_debug -= 1
705
706 print("===" + " SET_TRACE_4 ===")
707 assert input() == "c"
708 _pdb.do_continue("")
709
710 def do_continue(self, arg):
711 print("=== do_continue")
712
713 monkeypatch.setattr(_pytest.debugging, "pytestPDB", pytestPDBTest)
714
715 import pdb
716 monkeypatch.setattr(pdb, "set_trace", pytestPDBTest.set_trace)

Callers

nothing calls this directly

Calls 3

makepyfileMethod · 0.45
spawn_pytestMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected