summaryrefslogtreecommitdiff
path: root/testing/test_pdb.py
diff options
context:
space:
mode:
authorDaniel Hahler <git@thequod.de>2019-05-24 01:50:24 +0200
committerGitHub <noreply@github.com>2019-05-24 01:50:24 +0200
commitfa8a6584582d02acbd3fdaa8b7f3ac12b0ea907d (patch)
treeaccc55644183001478f04fe7734a1b78ff95c3bf /testing/test_pdb.py
parent66f20b6f5efa69f36b7e7e43874b516eb9add7b3 (diff)
parente0b584d0485329bad3b881c0c7a4e040f4b0b6dd (diff)
downloadpytest-fa8a6584582d02acbd3fdaa8b7f3ac12b0ea907d.tar.gz
Merge pull request #4908 from blueyed/pdb-pm-enter-hook
pdb: trigger pytest_enter_pdb hook with post-mortem
Diffstat (limited to 'testing/test_pdb.py')
-rw-r--r--testing/test_pdb.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/testing/test_pdb.py b/testing/test_pdb.py
index ed38a6133..4b084a26a 100644
--- a/testing/test_pdb.py
+++ b/testing/test_pdb.py
@@ -745,7 +745,8 @@ class TestPDB(object):
["E NameError: *xxx*", "*! *Exit: Quitting debugger !*"] # due to EOF
)
- def test_enter_leave_pdb_hooks_are_called(self, testdir):
+ @pytest.mark.parametrize("post_mortem", (False, True))
+ def test_enter_leave_pdb_hooks_are_called(self, post_mortem, testdir):
testdir.makeconftest(
"""
mypdb = None
@@ -774,16 +775,25 @@ class TestPDB(object):
"""
import pytest
- def test_foo():
+ def test_set_trace():
pytest.set_trace()
assert 0
+
+ def test_post_mortem():
+ assert 0
"""
)
- child = testdir.spawn_pytest(str(p1))
+ if post_mortem:
+ child = testdir.spawn_pytest(str(p1) + " --pdb -s -k test_post_mortem")
+ else:
+ child = testdir.spawn_pytest(str(p1) + " -k test_set_trace")
child.expect("enter_pdb_hook")
child.sendline("c")
- child.expect(r"PDB continue \(IO-capturing resumed\)")
- child.expect("Captured stdout call")
+ if post_mortem:
+ child.expect(r"PDB continue")
+ else:
+ child.expect(r"PDB continue \(IO-capturing resumed\)")
+ child.expect("Captured stdout call")
rest = child.read().decode("utf8")
assert "leave_pdb_hook" in rest
assert "1 failed" in rest