test
This commit is contained in:
parent
0ac85218d1
commit
c7b4b8cf6f
|
@ -12,6 +12,26 @@ def runpdb_and_get_report(testdir, source):
|
||||||
return reports[1]
|
return reports[1]
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def custom_pdb_calls():
|
||||||
|
called = []
|
||||||
|
|
||||||
|
# install dummy debugger class and track which methods were called on it
|
||||||
|
class _CustomPdb:
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
called.append("init")
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
called.append("reset")
|
||||||
|
|
||||||
|
def interaction(self, *args):
|
||||||
|
called.append("interaction")
|
||||||
|
|
||||||
|
_pytest._CustomPdb = _CustomPdb
|
||||||
|
return called
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TestPDB:
|
class TestPDB:
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
@ -334,22 +354,18 @@ class TestPDB:
|
||||||
if child.isalive():
|
if child.isalive():
|
||||||
child.wait()
|
child.wait()
|
||||||
|
|
||||||
def test_pdb_custom_cls(self, testdir):
|
def test_pdb_custom_cls(self, testdir, custom_pdb_calls):
|
||||||
called = []
|
p1 = testdir.makepyfile("""xxx """)
|
||||||
|
result = testdir.runpytest_inprocess(
|
||||||
|
"--pdb", "--pdbcls=_pytest:_CustomPdb", p1)
|
||||||
|
result.stdout.fnmatch_lines([
|
||||||
|
"*NameError*xxx*",
|
||||||
|
"*1 error*",
|
||||||
|
])
|
||||||
|
assert custom_pdb_calls == ["init", "reset", "interaction"]
|
||||||
|
|
||||||
# install dummy debugger class and track which methods were called on it
|
|
||||||
class _CustomPdb:
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
called.append("init")
|
|
||||||
|
|
||||||
def reset(self):
|
|
||||||
called.append("reset")
|
|
||||||
|
|
||||||
def interaction(self, *args):
|
|
||||||
called.append("interaction")
|
|
||||||
|
|
||||||
_pytest._CustomPdb = _CustomPdb
|
|
||||||
|
|
||||||
|
def test_pdb_custom_cls_without_pdb(self, testdir, custom_pdb_calls):
|
||||||
p1 = testdir.makepyfile("""xxx """)
|
p1 = testdir.makepyfile("""xxx """)
|
||||||
result = testdir.runpytest_inprocess(
|
result = testdir.runpytest_inprocess(
|
||||||
"--pdbcls=_pytest:_CustomPdb", p1)
|
"--pdbcls=_pytest:_CustomPdb", p1)
|
||||||
|
@ -357,4 +373,4 @@ class TestPDB:
|
||||||
"*NameError*xxx*",
|
"*NameError*xxx*",
|
||||||
"*1 error*",
|
"*1 error*",
|
||||||
])
|
])
|
||||||
assert called == ["init", "reset", "interaction"]
|
assert custom_pdb_calls == []
|
||||||
|
|
Loading…
Reference in New Issue