diff options
author | Tian Gao <gaogaotiantian@hotmail.com> | 2023-12-07 11:19:33 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-07 11:19:33 (GMT) |
commit | 3d712a9f4c9f366edbe16b804ec4f6ae50b0a59f (patch) | |
tree | 4b6915cce4e4cbd629678b965d47e2949fd30ceb /Lib/test/test_pdb.py | |
parent | 4b125dd31a634871d3b2d06ebfd1b9aef539766b (diff) | |
download | cpython-3d712a9f4c9f366edbe16b804ec4f6ae50b0a59f.zip cpython-3d712a9f4c9f366edbe16b804ec4f6ae50b0a59f.tar.gz cpython-3d712a9f4c9f366edbe16b804ec4f6ae50b0a59f.tar.bz2 |
gh-102980: Redirect output of pdb's `interact` command, add tests and improve docs (#111194)
Diffstat (limited to 'Lib/test/test_pdb.py')
-rw-r--r-- | Lib/test/test_pdb.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py index 50d8c8f..d53fe3c 100644 --- a/Lib/test/test_pdb.py +++ b/Lib/test/test_pdb.py @@ -778,6 +778,59 @@ def test_pdb_where_command(): (Pdb) continue """ +def test_pdb_interact_command(): + """Test interact command + + >>> g = 0 + >>> dict_g = {} + + >>> def test_function(): + ... x = 1 + ... lst_local = [] + ... import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace() + + >>> with PdbTestInput([ # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE + ... 'interact', + ... 'x', + ... 'g', + ... 'x = 2', + ... 'g = 3', + ... 'dict_g["a"] = True', + ... 'lst_local.append(x)', + ... 'exit()', + ... 'p x', + ... 'p g', + ... 'p dict_g', + ... 'p lst_local', + ... 'continue', + ... ]): + ... test_function() + --Return-- + > <doctest test.test_pdb.test_pdb_interact_command[2]>(4)test_function()->None + -> import pdb; pdb.Pdb(nosigint=True, readrc=False).set_trace() + (Pdb) interact + *pdb interact start* + ... x + 1 + ... g + 0 + ... x = 2 + ... g = 3 + ... dict_g["a"] = True + ... lst_local.append(x) + ... exit() + *exit from pdb interact command* + (Pdb) p x + 1 + (Pdb) p g + 0 + (Pdb) p dict_g + {'a': True} + (Pdb) p lst_local + [2] + (Pdb) continue + """ + def test_convenience_variables(): """Test convenience variables |