Merge pull request #5074 from blueyed/trace
pdb: add test for --trace with --pdbcls
This commit is contained in:
commit
3fa329c9e9
|
@ -256,7 +256,7 @@ def _test_pytest_function(pyfuncitem):
|
||||||
_pdb = pytestPDB._init_pdb()
|
_pdb = pytestPDB._init_pdb()
|
||||||
testfunction = pyfuncitem.obj
|
testfunction = pyfuncitem.obj
|
||||||
pyfuncitem.obj = _pdb.runcall
|
pyfuncitem.obj = _pdb.runcall
|
||||||
if "func" in pyfuncitem._fixtureinfo.argnames: # noqa
|
if "func" in pyfuncitem._fixtureinfo.argnames: # pragma: no branch
|
||||||
raise ValueError("--trace can't be used with a fixture named func!")
|
raise ValueError("--trace can't be used with a fixture named func!")
|
||||||
pyfuncitem.funcargs["func"] = testfunction
|
pyfuncitem.funcargs["func"] = testfunction
|
||||||
new_list = list(pyfuncitem._fixtureinfo.argnames)
|
new_list = list(pyfuncitem._fixtureinfo.argnames)
|
||||||
|
|
|
@ -1148,7 +1148,11 @@ def test_pdbcls_via_local_module(testdir):
|
||||||
class Wrapped:
|
class Wrapped:
|
||||||
class MyPdb:
|
class MyPdb:
|
||||||
def set_trace(self, *args):
|
def set_trace(self, *args):
|
||||||
print("mypdb_called", args)
|
print("settrace_called", args)
|
||||||
|
|
||||||
|
def runcall(self, *args, **kwds):
|
||||||
|
print("runcall_called", args, kwds)
|
||||||
|
assert "func" in kwds
|
||||||
""",
|
""",
|
||||||
)
|
)
|
||||||
result = testdir.runpytest(
|
result = testdir.runpytest(
|
||||||
|
@ -1165,4 +1169,11 @@ def test_pdbcls_via_local_module(testdir):
|
||||||
str(p1), "--pdbcls=mypdb:Wrapped.MyPdb", syspathinsert=True
|
str(p1), "--pdbcls=mypdb:Wrapped.MyPdb", syspathinsert=True
|
||||||
)
|
)
|
||||||
assert result.ret == 0
|
assert result.ret == 0
|
||||||
result.stdout.fnmatch_lines(["*mypdb_called*", "* 1 passed in *"])
|
result.stdout.fnmatch_lines(["*settrace_called*", "* 1 passed in *"])
|
||||||
|
|
||||||
|
# Ensure that it also works with --trace.
|
||||||
|
result = testdir.runpytest(
|
||||||
|
str(p1), "--pdbcls=mypdb:Wrapped.MyPdb", "--trace", syspathinsert=True
|
||||||
|
)
|
||||||
|
assert result.ret == 0
|
||||||
|
result.stdout.fnmatch_lines(["*runcall_called*", "* 1 passed in *"])
|
||||||
|
|
Loading…
Reference in New Issue