summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pdb.py
diff options
context:
space:
mode:
authorgaogaotiantian <gaogaotiantian@hotmail.com>2023-03-29 10:09:12 (GMT)
committerGitHub <noreply@github.com>2023-03-29 10:09:12 (GMT)
commite375bff03736f809fbc234010c087ef9d7e0d384 (patch)
treeb148534327f0f7f4dfc2705f85fba01974b96e22 /Lib/test/test_pdb.py
parentd835b3f05de7e2d800138e5969eeb9656b0ed860 (diff)
downloadcpython-e375bff03736f809fbc234010c087ef9d7e0d384.zip
cpython-e375bff03736f809fbc234010c087ef9d7e0d384.tar.gz
cpython-e375bff03736f809fbc234010c087ef9d7e0d384.tar.bz2
gh-103068: Check condition expression of breakpoints for pdb (#103069)
Co-authored-by: Ɓukasz Langa <lukasz@langa.pl> Co-authored-by: Artem Mukhin <ortem00@gmail.com>
Diffstat (limited to 'Lib/test/test_pdb.py')
-rw-r--r--Lib/test/test_pdb.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
index ae9c5d7..de2bab4 100644
--- a/Lib/test/test_pdb.py
+++ b/Lib/test/test_pdb.py
@@ -240,9 +240,11 @@ def test_pdb_breakpoint_commands():
>>> with PdbTestInput([ # doctest: +NORMALIZE_WHITESPACE
... 'break 3',
+ ... 'break 4, +',
... 'disable 1',
... 'ignore 1 10',
... 'condition 1 1 < 2',
+ ... 'condition 1 1 <',
... 'break 4',
... 'break 4',
... 'break',
@@ -264,6 +266,8 @@ def test_pdb_breakpoint_commands():
... 'commands 10', # out of range
... 'commands a', # display help
... 'commands 4', # already deleted
+ ... 'break 6, undefined', # condition causing `NameError` during evaluation
+ ... 'continue', # will stop, ignoring runtime error
... 'continue',
... ]):
... test_function()
@@ -271,12 +275,16 @@ def test_pdb_breakpoint_commands():
-> print(1)
(Pdb) break 3
Breakpoint 1 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:3
+ (Pdb) break 4, +
+ *** Invalid condition +: SyntaxError: invalid syntax
(Pdb) disable 1
Disabled breakpoint 1 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:3
(Pdb) ignore 1 10
Will ignore next 10 crossings of breakpoint 1.
(Pdb) condition 1 1 < 2
New condition set for breakpoint 1.
+ (Pdb) condition 1 1 <
+ *** Invalid condition 1 <: SyntaxError: invalid syntax
(Pdb) break 4
Breakpoint 2 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:4
(Pdb) break 4
@@ -331,8 +339,13 @@ def test_pdb_breakpoint_commands():
end
(Pdb) commands 4
*** cannot set commands: Breakpoint 4 already deleted
+ (Pdb) break 6, undefined
+ Breakpoint 5 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:6
(Pdb) continue
3
+ > <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>(6)test_function()
+ -> print(4)
+ (Pdb) continue
4
"""
@@ -597,13 +610,14 @@ def test_pdb_display_command():
... 'undisplay',
... 'display a < 1',
... 'n',
+ ... 'display undefined',
... 'continue',
... ]):
... test_function()
> <doctest test.test_pdb.test_pdb_display_command[0]>(4)test_function()
-> a = 1
(Pdb) display +
- Unable to display +: ** raised SyntaxError: invalid syntax **
+ *** Unable to display +: SyntaxError: invalid syntax
(Pdb) display
No expression is being displayed
(Pdb) display a
@@ -627,6 +641,8 @@ def test_pdb_display_command():
(Pdb) n
> <doctest test.test_pdb.test_pdb_display_command[0]>(7)test_function()
-> a = 4
+ (Pdb) display undefined
+ display undefined: ** raised NameError: name 'undefined' is not defined **
(Pdb) continue
"""