GH-103124: Multiline statement support for pdb (GH-103125)

This commit is contained in:
Tian Gao 2023-06-15 16:34:42 -07:00 committed by GitHub
parent a4056c8f9c
commit 25a64fd28a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 56 additions and 4 deletions

View file

@ -389,7 +389,7 @@ def test_pdb_breakpoints_preserved_across_interactive_sessions():
1 breakpoint keep yes at ...test_pdb.py:...
2 breakpoint keep yes at ...test_pdb.py:...
(Pdb) break pdb.find_function
Breakpoint 3 at ...pdb.py:97
Breakpoint 3 at ...pdb.py:...
(Pdb) break
Num Type Disp Enb Where
1 breakpoint keep yes at ...test_pdb.py:...
@ -1589,6 +1589,32 @@ def test_pdb_next_command_subiterator():
(Pdb) continue
"""
def test_pdb_multiline_statement():
"""Test for multiline statement
>>> def test_function():
... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace()
... pass
>>> with PdbTestInput([ # doctest: +NORMALIZE_WHITESPACE
... 'def f(x):',
... ' return x * 2',
... '',
... 'f(2)',
... 'c'
... ]):
... test_function()
> <doctest test.test_pdb.test_pdb_multiline_statement[0]>(3)test_function()
-> pass
(Pdb) def f(x):
... return x * 2
...
(Pdb) f(2)
4
(Pdb) c
"""
def test_pdb_issue_20766():
"""Test for reference leaks when the SIGINT handler is set.
@ -2362,7 +2388,7 @@ def bœr():
def test_errors_in_command(self):
commands = "\n".join([
'print(',
'print(]',
'debug print(',
'debug doesnotexist',
'c',
@ -2371,7 +2397,8 @@ def bœr():
self.assertEqual(stdout.splitlines()[1:], [
'-> pass',
'(Pdb) *** SyntaxError: \'(\' was never closed',
"(Pdb) *** SyntaxError: closing parenthesis ']' does not match opening "
"parenthesis '('",
'(Pdb) ENTERING RECURSIVE DEBUGGER',
'*** SyntaxError: \'(\' was never closed',