MCPcopy
hub / github.com/pytest-dev/pytest / _init_pdb

Method _init_pdb

src/_pytest/debugging.py:240–276  ·  view source on GitHub ↗

Initialize PDB debugging, dropping any IO capturing.

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

Source from the content-addressed store, hash-verified

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