Skip to content

Commit bc786b2

Browse files
committed
tests: fix test_trace_after_runpytest
It was not really testing what it was supposed to test (e.g. the inner test was not run in the first place).
1 parent 4ccaa98 commit bc786b2

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

testing/test_pdb.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,24 +1024,28 @@ def test_trace_after_runpytest(testdir):
10241024
from _pytest.debugging import pytestPDB
10251025
10261026
def test_outer(testdir):
1027-
from _pytest.debugging import pytestPDB
1028-
10291027
assert len(pytestPDB._saved) == 1
10301028
1031-
testdir.runpytest("-k test_inner")
1029+
testdir.makepyfile(
1030+
\"""
1031+
from _pytest.debugging import pytestPDB
10321032
1033-
__import__('pdb').set_trace()
1033+
def test_inner():
1034+
assert len(pytestPDB._saved) == 2
1035+
print()
1036+
print("test_inner_" + "end")
1037+
\"""
1038+
)
1039+
1040+
result = testdir.runpytest("-s", "-k", "test_inner")
1041+
assert result.ret == 0
10341042
1035-
def test_inner(testdir):
1036-
assert len(pytestPDB._saved) == 2
1043+
assert len(pytestPDB._saved) == 1
10371044
"""
10381045
)
1039-
child = testdir.spawn_pytest("-p pytester %s -k test_outer" % p1)
1040-
child.expect(r"\(Pdb")
1041-
child.sendline("c")
1042-
rest = child.read().decode("utf8")
1043-
TestPDB.flush(child)
1044-
assert child.exitstatus == 0, rest
1046+
result = testdir.runpytest_subprocess("-s", "-p", "pytester", str(p1))
1047+
result.stdout.fnmatch_lines(["test_inner_end"])
1048+
assert result.ret == 0
10451049

10461050

10471051
def test_quit_with_swallowed_SystemExit(testdir):

0 commit comments

Comments
 (0)