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

Method _init_pdb

src/_pytest/debugging.py:238–275  ·  view source on GitHub ↗

Initialize PDB debugging, dropping any IO capturing.

(cls, method, *args, **kwargs)

Source from the content-addressed store, hash-verified

236
237 @classmethod
238 def _init_pdb(cls, method, *args, **kwargs):
239 """Initialize PDB debugging, dropping any IO capturing."""
240 import _pytest.config
241
242 if cls._pluginmanager is None:
243 capman: Optional[CaptureManager] = None
244 else:
245 capman = cls._pluginmanager.getplugin("capturemanager")
246 if capman:
247 capman.suspend(in_=True)
248
249 if cls._config:
250 tw = _pytest.config.create_terminal_writer(cls._config)
251 tw.line()
252
253 if cls._recursive_debug == 0:
254 # Handle header similar to pdb.set_trace in py37+.
255 header = kwargs.pop("header", None)
256 if header is not None:
257 tw.sep(">", header)
258 else:
259 capturing = cls._is_capturing(capman)
260 if capturing == "global":
261 tw.sep(">", f"PDB {method} (IO-capturing turned off)")
262 elif capturing:
263 tw.sep(
264 ">",
265 "PDB %s (IO-capturing turned off for %s)"
266 % (method, capturing),
267 )
268 else:
269 tw.sep(">", f"PDB {method}")
270
271 _pdb = cls._import_pdb_cls(capman)(**kwargs)
272
273 if cls._pluginmanager:
274 cls._pluginmanager.hook.pytest_enter_pdb(config=cls._config, pdb=_pdb)
275 return _pdb
276
277 @classmethod
278 def set_trace(cls, *args, **kwargs) -> None:

Callers 3

set_traceMethod · 0.80
post_mortemFunction · 0.80

Calls 7

getpluginMethod · 0.80
popMethod · 0.80
_is_capturingMethod · 0.80
_import_pdb_clsMethod · 0.80
suspendMethod · 0.45
lineMethod · 0.45
sepMethod · 0.45

Tested by

no test coverage detected