Change the Python function object of the given Function item by a wrapper which actually enters pdb before calling the python function itself, effectively leaving the user in the pdb prompt in the first statement of the function.
(pyfuncitem)
| 308 | |
| 309 | |
| 310 | def wrap_pytest_function_for_tracing(pyfuncitem): |
| 311 | """Change the Python function object of the given Function item by a |
| 312 | wrapper which actually enters pdb before calling the python function |
| 313 | itself, effectively leaving the user in the pdb prompt in the first |
| 314 | statement of the function.""" |
| 315 | _pdb = pytestPDB._init_pdb("runcall") |
| 316 | testfunction = pyfuncitem.obj |
| 317 | |
| 318 | # we can't just return `partial(pdb.runcall, testfunction)` because (on |
| 319 | # python < 3.7.4) runcall's first param is `func`, which means we'd get |
| 320 | # an exception if one of the kwargs to testfunction was called `func`. |
| 321 | @functools.wraps(testfunction) |
| 322 | def wrapper(*args, **kwargs): |
| 323 | func = functools.partial(testfunction, *args, **kwargs) |
| 324 | _pdb.runcall(func) |
| 325 | |
| 326 | pyfuncitem.obj = wrapper |
| 327 | |
| 328 | |
| 329 | def maybe_wrap_pytest_function_for_tracing(pyfuncitem): |
no test coverage detected