Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
davidszotten committed Sep 19, 2016
1 parent 425c5f0 commit 3339921
Showing 1 changed file with 31 additions and 15 deletions.
46 changes: 31 additions & 15 deletions testing/test_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,26 @@ def runpdb_and_get_report(testdir, source):
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:

@pytest.fixture
Expand Down Expand Up @@ -334,27 +354,23 @@ def test_foo():
if child.isalive():
child.wait()

def test_pdb_custom_cls(self, testdir):
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")
def test_pdb_custom_cls(self, testdir, custom_pdb_calls):
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"]

_pytest._CustomPdb = _CustomPdb

def test_pdb_custom_cls_without_pdb(self, testdir, custom_pdb_calls):
p1 = testdir.makepyfile("""xxx """)
result = testdir.runpytest_inprocess(
"--pdbcls=_pytest:_CustomPdb", p1)
result.stdout.fnmatch_lines([
"*NameError*xxx*",
"*1 error*",
])
assert called == ["init", "reset", "interaction"]
assert custom_pdb_calls == []

0 comments on commit 3339921

Please sign in to comment.