(pytester: Pytester)
| 1298 | |
| 1299 | |
| 1300 | def test_pdb_wrapper_class_is_reused(pytester: Pytester) -> None: |
| 1301 | p1 = pytester.makepyfile( |
| 1302 | """ |
| 1303 | def test(): |
| 1304 | __import__("pdb").set_trace() |
| 1305 | __import__("pdb").set_trace() |
| 1306 | |
| 1307 | import mypdb |
| 1308 | instances = mypdb.instances |
| 1309 | assert len(instances) == 2 |
| 1310 | assert instances[0].__class__ is instances[1].__class__ |
| 1311 | """, |
| 1312 | mypdb=""" |
| 1313 | instances = [] |
| 1314 | |
| 1315 | class MyPdb: |
| 1316 | def __init__(self, *args, **kwargs): |
| 1317 | instances.append(self) |
| 1318 | |
| 1319 | def set_trace(self, *args): |
| 1320 | print("set_trace_called", args) |
| 1321 | """, |
| 1322 | ) |
| 1323 | result = pytester.runpytest(str(p1), "--pdbcls=mypdb:MyPdb", syspathinsert=True) |
| 1324 | assert result.ret == 0 |
| 1325 | result.stdout.fnmatch_lines( |
| 1326 | ["*set_trace_called*", "*set_trace_called*", "* 1 passed in *"] |
| 1327 | ) |
nothing calls this directly
no test coverage detected