mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-112343: pdb: Use tokenize to replace convenience variables (#112380)
This commit is contained in:
parent
f49752552e
commit
5c351fc85a
3 changed files with 45 additions and 1 deletions
|
@ -847,9 +847,12 @@ def test_convenience_variables():
|
|||
|
||||
>>> with PdbTestInput([ # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
|
||||
... '$_frame.f_lineno', # Check frame convenience variable
|
||||
... '$ _frame', # This should be a syntax error
|
||||
... '$a = 10', # Set a convenience variable
|
||||
... '$a', # Print its value
|
||||
... 'p "$a"', # Print the string $a
|
||||
... 'p $a + 2', # Do some calculation
|
||||
... 'p f"$a = {$a}"', # Make sure $ in string is not converted and f-string works
|
||||
... 'u', # Switch frame
|
||||
... '$_frame.f_lineno', # Make sure the frame changed
|
||||
... '$a', # Make sure the value persists
|
||||
|
@ -869,11 +872,17 @@ def test_convenience_variables():
|
|||
-> try:
|
||||
(Pdb) $_frame.f_lineno
|
||||
3
|
||||
(Pdb) $ _frame
|
||||
*** SyntaxError: invalid syntax
|
||||
(Pdb) $a = 10
|
||||
(Pdb) $a
|
||||
10
|
||||
(Pdb) p "$a"
|
||||
'$a'
|
||||
(Pdb) p $a + 2
|
||||
12
|
||||
(Pdb) p f"$a = {$a}"
|
||||
'$a = 10'
|
||||
(Pdb) u
|
||||
> <doctest test.test_pdb.test_convenience_variables[1]>(2)test_function()
|
||||
-> util_function()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue