Skip to content

Commit dda2193

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 cc464f6 commit dda2193

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
@@ -1027,24 +1027,28 @@ def test_trace_after_runpytest(testdir):
10271027
from _pytest.debugging import pytestPDB
10281028
10291029
def test_outer(testdir):
1030-
from _pytest.debugging import pytestPDB
1031-
10321030
assert len(pytestPDB._saved) == 1
10331031
1034-
testdir.runpytest("-k test_inner")
1032+
testdir.makepyfile(
1033+
\"""
1034+
from _pytest.debugging import pytestPDB
10351035
1036-
__import__('pdb').set_trace()
1036+
def test_inner():
1037+
assert len(pytestPDB._saved) == 2
1038+
print()
1039+
print("test_inner_" + "end")
1040+
\"""
1041+
)
1042+
1043+
result = testdir.runpytest("-s", "-k", "test_inner")
1044+
assert result.ret == 0
10371045
1038-
def test_inner(testdir):
1039-
assert len(pytestPDB._saved) == 2
1046+
assert len(pytestPDB._saved) == 1
10401047
"""
10411048
)
1042-
child = testdir.spawn_pytest("-p pytester %s -k test_outer" % p1)
1043-
child.expect(r"\(Pdb")
1044-
child.sendline("c")
1045-
rest = child.read().decode("utf8")
1046-
TestPDB.flush(child)
1047-
assert child.exitstatus == 0, rest
1049+
result = testdir.runpytest_subprocess("-s", "-p", "pytester", str(p1))
1050+
result.stdout.fnmatch_lines(["test_inner_end"])
1051+
assert result.ret == 0
10481052

10491053

10501054
def test_quit_with_swallowed_SystemExit(testdir):

0 commit comments

Comments
 (0)