Skip to content

Commit 3fa329c

Browse files
authored
Merge pull request #5074 from blueyed/trace
pdb: add test for --trace with --pdbcls
2 parents b549438 + 4fb7a91 commit 3fa329c

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/_pytest/debugging.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def _test_pytest_function(pyfuncitem):
256256
_pdb = pytestPDB._init_pdb()
257257
testfunction = pyfuncitem.obj
258258
pyfuncitem.obj = _pdb.runcall
259-
if "func" in pyfuncitem._fixtureinfo.argnames: # noqa
259+
if "func" in pyfuncitem._fixtureinfo.argnames: # pragma: no branch
260260
raise ValueError("--trace can't be used with a fixture named func!")
261261
pyfuncitem.funcargs["func"] = testfunction
262262
new_list = list(pyfuncitem._fixtureinfo.argnames)

testing/test_pdb.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,7 +1148,11 @@ def test():
11481148
class Wrapped:
11491149
class MyPdb:
11501150
def set_trace(self, *args):
1151-
print("mypdb_called", args)
1151+
print("settrace_called", args)
1152+
1153+
def runcall(self, *args, **kwds):
1154+
print("runcall_called", args, kwds)
1155+
assert "func" in kwds
11521156
""",
11531157
)
11541158
result = testdir.runpytest(
@@ -1165,4 +1169,11 @@ def set_trace(self, *args):
11651169
str(p1), "--pdbcls=mypdb:Wrapped.MyPdb", syspathinsert=True
11661170
)
11671171
assert result.ret == 0
1168-
result.stdout.fnmatch_lines(["*mypdb_called*", "* 1 passed in *"])
1172+
result.stdout.fnmatch_lines(["*settrace_called*", "* 1 passed in *"])
1173+
1174+
# Ensure that it also works with --trace.
1175+
result = testdir.runpytest(
1176+
str(p1), "--pdbcls=mypdb:Wrapped.MyPdb", "--trace", syspathinsert=True
1177+
)
1178+
assert result.ret == 0
1179+
result.stdout.fnmatch_lines(["*runcall_called*", "* 1 passed in *"])

0 commit comments

Comments
 (0)