diff options
author | Daniel Hahler <git@thequod.de> | 2019-05-11 14:30:54 +0200 |
---|---|---|
committer | Daniel Hahler <git@thequod.de> | 2019-05-12 09:33:34 +0200 |
commit | dda21935a73fea602ba128310585e8f9c5934fcb (patch) | |
tree | 976446be1b3d3fe59944836e9e6591cd8e909f5a /testing/test_pdb.py | |
parent | cc464f6b96e59deafbe1e393beba7a21351c2e9d (diff) | |
download | pytest-dda21935a73fea602ba128310585e8f9c5934fcb.tar.gz |
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).
Diffstat (limited to 'testing/test_pdb.py')
-rw-r--r-- | testing/test_pdb.py | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/testing/test_pdb.py b/testing/test_pdb.py index 3b21bacd9..c0ba7159b 100644 --- a/testing/test_pdb.py +++ b/testing/test_pdb.py @@ -1027,24 +1027,28 @@ def test_trace_after_runpytest(testdir): from _pytest.debugging import pytestPDB def test_outer(testdir): - from _pytest.debugging import pytestPDB - assert len(pytestPDB._saved) == 1 - testdir.runpytest("-k test_inner") + testdir.makepyfile( + \""" + from _pytest.debugging import pytestPDB - __import__('pdb').set_trace() + def test_inner(): + assert len(pytestPDB._saved) == 2 + print() + print("test_inner_" + "end") + \""" + ) + + result = testdir.runpytest("-s", "-k", "test_inner") + assert result.ret == 0 - def test_inner(testdir): - assert len(pytestPDB._saved) == 2 + assert len(pytestPDB._saved) == 1 """ ) - child = testdir.spawn_pytest("-p pytester %s -k test_outer" % p1) - child.expect(r"\(Pdb") - child.sendline("c") - rest = child.read().decode("utf8") - TestPDB.flush(child) - assert child.exitstatus == 0, rest + result = testdir.runpytest_subprocess("-s", "-p", "pytester", str(p1)) + result.stdout.fnmatch_lines(["test_inner_end"]) + assert result.ret == 0 def test_quit_with_swallowed_SystemExit(testdir): |