Skip to content

Commit ae067df

Browse files
committed
add test_pdb_continue_with_recursive_debug
1 parent 40718ef commit ae067df

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

testing/test_pdb.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,57 @@ def test_1():
604604
child.expect("1 passed")
605605
self.flush(child)
606606

607+
@pytest.mark.parametrize("capture", (True, False))
608+
def test_pdb_continue_with_recursive_debug(self, capture, testdir):
609+
"""Full coverage for do_debug without capturing.
610+
611+
This is very similar to test_pdb_interaction_continue_recursive, but
612+
simpler, and providing more coverage.
613+
"""
614+
p1 = testdir.makepyfile(
615+
"""
616+
def set_trace():
617+
__import__('pdb').set_trace()
618+
619+
def test_1():
620+
set_trace()
621+
"""
622+
)
623+
if capture:
624+
child = testdir.spawn_pytest("%s" % p1)
625+
else:
626+
child = testdir.spawn_pytest("-s %s" % p1)
627+
child.expect("Pdb")
628+
before = child.before.decode("utf8")
629+
if capture:
630+
assert ">>> PDB set_trace (IO-capturing turned off) >>>" in before
631+
else:
632+
assert ">>> PDB set_trace >>>" in before
633+
child.sendline("debug set_trace()")
634+
child.expect(r"\(Pdb.*")
635+
before = child.before.decode("utf8")
636+
assert "\r\nENTERING RECURSIVE DEBUGGER\r\n" in before
637+
child.sendline("c")
638+
child.expect(r"\(Pdb.*")
639+
640+
# No continue message with recursive debugging.
641+
before = child.before.decode("utf8")
642+
assert ">>> PDB continue " not in before
643+
# No extra newline.
644+
assert before.startswith("c\r\n\r\n--Return--")
645+
646+
child.sendline("c")
647+
child.expect("Pdb")
648+
before = child.before.decode("utf8")
649+
assert "\r\nLEAVING RECURSIVE DEBUGGER\r\n" in before
650+
child.sendline("c")
651+
rest = child.read().decode("utf8")
652+
if capture:
653+
assert "> PDB continue (IO-capturing resumed) >" in rest
654+
else:
655+
assert "> PDB continue >" in rest
656+
assert "1 passed in" in rest
657+
607658
def test_pdb_used_outside_test(self, testdir):
608659
p1 = testdir.makepyfile(
609660
"""

0 commit comments

Comments
 (0)