(cls, capman: CaptureManager | None)
| 108 | |
| 109 | @classmethod |
| 110 | def _import_pdb_cls(cls, capman: CaptureManager | None): |
| 111 | if not cls._config: |
| 112 | import pdb |
| 113 | |
| 114 | # Happens when using pytest.set_trace outside of a test. |
| 115 | return pdb.Pdb |
| 116 | |
| 117 | usepdb_cls = cls._config.getvalue("usepdb_cls") |
| 118 | |
| 119 | if cls._wrapped_pdb_cls and cls._wrapped_pdb_cls[0] == usepdb_cls: |
| 120 | return cls._wrapped_pdb_cls[1] |
| 121 | |
| 122 | if usepdb_cls: |
| 123 | modname, classname = usepdb_cls |
| 124 | |
| 125 | try: |
| 126 | mod = importlib.import_module(modname) |
| 127 | |
| 128 | # Handle --pdbcls=pdb:pdb.Pdb (useful e.g. with pdbpp). |
| 129 | parts = classname.split(".") |
| 130 | pdb_cls = getattr(mod, parts[0]) |
| 131 | for part in parts[1:]: |
| 132 | pdb_cls = getattr(pdb_cls, part) |
| 133 | except Exception as exc: |
| 134 | value = ":".join((modname, classname)) |
| 135 | raise UsageError( |
| 136 | f"--pdbcls: could not import {value!r}: {exc}" |
| 137 | ) from exc |
| 138 | else: |
| 139 | import pdb |
| 140 | |
| 141 | pdb_cls = pdb.Pdb |
| 142 | |
| 143 | wrapped_cls = cls._get_pdb_wrapper_class(pdb_cls, capman) |
| 144 | cls._wrapped_pdb_cls = (usepdb_cls, wrapped_cls) |
| 145 | return wrapped_cls |
| 146 | |
| 147 | @classmethod |
| 148 | def _get_pdb_wrapper_class(cls, pdb_cls, capman: CaptureManager | None): |
no test coverage detected