docstr: Simulates pdbpp, which injects Pdb into do_debug, and uses
  self.__class__ in do_continue.
docstr_tok: ["Simulates","pdbpp",",","which","injects","Pdb","into","do_debug",",","and","uses","self.__class__","in","do_continue","."]
code: def test_pdb_with_injected_do_debug(self, pytester: Pytester) -> None:
      """Simulates pdbpp, which injects Pdb into do_debug, and uses
      self.__class__ in do_continue.
      """
      p1 = pytester.makepyfile(
          mytest="""
              import pdb
              import pytest
  
              count_continue = 0
  
              class CustomPdb(pdb.Pdb, object):
                  def do_debug(self, arg):
                      import sys
                      import types
  
                      do_debug_func = pdb.Pdb.do_debug
  
                      newglobals = do_debug_func.__globals__.copy()
                      newglobals['Pdb'] = self.__class__
                      orig_do_debug = types.FunctionType(
                          do_debug_func.__code__, newglobals,
                          do_debug_func.__name__, do_debug_func.__defaults__,
                      )
                      return orig_do_debug(self, arg)
                  do_debug.__doc__ = pdb.Pdb.do_debug.__doc__
  
                  def do_continue(self, *args, **kwargs):
                      global count_continue
                      count_continue += 1
                      return super(CustomPdb, self).do_continue(*args, **kwargs)
  
              def foo():
                  print("print_from_foo")
  
              def test_1():
                  i = 0
                  print("hello17")
                  pytest.set_trace()
                  x = 3
                  print("hello18")
  
                  assert count_continue == 2, "unexpected_failure: %d != 2" % count_continue
                  pytest.fail("expected_failure")
          """
      )
      child = pytester.spawn_pytest(
          "--pdbcls=mytest:CustomPdb %s" % str(p1)
      )
      child.expect(r"PDB set_trace \(IO-capturing turned off\)")
      child.expect(r"\n\(Pdb")
      child.sendline("debug foo()")
      child.expect("ENTERING RECURSIVE DEBUGGER")
      child.expect(r"\n\(\(Pdb")
      child.sendline("c")
      child.expect("LEAVING RECURSIVE DEBUGGER")
      assert b"PDB continue" not in child.before
      # No extra newline.
      assert child.before.endswith(b"c\r\nprint_from_foo\r\n")
  
      # set_debug should not raise outcomes. Exit, if used recursively.
      child.sendline("debug 42")
      child.sendline("q")
      child.expect("LEAVING RECURSIVE DEBUGGER")
      assert b"ENTERING RECURSIVE DEBUGGER" in child.before
      assert b"Quitting debugger" not in child.before
  
      child.sendline("c")
      child.expect(r"PDB continue \(IO-capturing resumed\)")
      rest = child.read().decode("utf8")
      assert "hello17" in rest  # out is captured
      assert "hello18" in rest  # out is captured
      assert "1 failed" in rest
      assert "Failed: expected_failure" in rest
      assert "AssertionError: unexpected_failure" not in rest
      self.flush(child)
  
imports: import os
  import sys
  from typing import List
  import _pytest._code
  import pytest
  from _pytest.debugging import _validate_usepdb_cls
  from _pytest.monkeypatch import MonkeyPatch
  from _pytest.pytester import Pytester
label_desc: Use image node_id 28 for calling the TestPDB obj's underlying member method code with example usage: obj.test_pdb_with_injected_do_debug(pytester) without return types