| 63 | |
| 64 | |
| 65 | def pytest_configure(config: Config) -> None: |
| 66 | import pdb |
| 67 | |
| 68 | if config.getvalue("trace"): |
| 69 | config.pluginmanager.register(PdbTrace(), "pdbtrace") |
| 70 | if config.getvalue("usepdb"): |
| 71 | config.pluginmanager.register(PdbInvoke(), "pdbinvoke") |
| 72 | |
| 73 | pytestPDB._saved.append( |
| 74 | (pdb.set_trace, pytestPDB._pluginmanager, pytestPDB._config) |
| 75 | ) |
| 76 | pdb.set_trace = pytestPDB.set_trace |
| 77 | pytestPDB._pluginmanager = config.pluginmanager |
| 78 | pytestPDB._config = config |
| 79 | |
| 80 | # NOTE: not using pytest_unconfigure, since it might get called although |
| 81 | # pytest_configure was not (if another plugin raises UsageError). |
| 82 | def fin() -> None: |
| 83 | ( |
| 84 | pdb.set_trace, |
| 85 | pytestPDB._pluginmanager, |
| 86 | pytestPDB._config, |
| 87 | ) = pytestPDB._saved.pop() |
| 88 | |
| 89 | config.add_cleanup(fin) |
| 90 | |
| 91 | |
| 92 | class pytestPDB: |