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