diff options
author | Georg Brandl <georg@python.org> | 2010-07-30 17:04:28 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2010-07-30 17:04:28 (GMT) |
commit | e59ca2afe3a84c7262add278d36a0f890ca379f2 (patch) | |
tree | 8db088814f9f9cfb4c088854582e54a60deae1aa /Lib/test/test_pdb.py | |
parent | 0d08962659faf137927f95233e3a7d0480325131 (diff) | |
download | cpython-e59ca2afe3a84c7262add278d36a0f890ca379f2.zip cpython-e59ca2afe3a84c7262add278d36a0f890ca379f2.tar.gz cpython-e59ca2afe3a84c7262add278d36a0f890ca379f2.tar.bz2 |
Add "longlist" and "source" commands, ideas borrowed from pdb++ by Antonio Cuni.
Diffstat (limited to 'Lib/test/test_pdb.py')
-rw-r--r-- | Lib/test/test_pdb.py | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py index aab6962..b2a441d 100644 --- a/Lib/test/test_pdb.py +++ b/Lib/test/test_pdb.py @@ -257,6 +257,105 @@ def test_pdb_breakpoint_commands(): """ +def do_nothing(): + pass + +def do_something(): + print(42) + +def test_list_commands(): + """Test the list and source commands of pdb. + + >>> def test_function_2(foo): + ... import test_pdb + ... test_pdb.do_nothing() + ... 'some...' + ... 'more...' + ... 'code...' + ... 'to...' + ... 'make...' + ... 'a...' + ... 'long...' + ... 'listing...' + ... 'useful...' + ... '...' + ... '...' + ... return foo + + >>> def test_function(): + ... import pdb; pdb.Pdb().set_trace() + ... ret = test_function_2('baz') + + >>> with PdbTestInput([ # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE + ... 'list', # list first function + ... 'step', # step into second function + ... 'list', # list second function + ... 'list', # continue listing to EOF + ... 'list 1,3', # list specific lines + ... 'list x', # invalid argument + ... 'next', # step to import + ... 'next', # step over import + ... 'step', # step into do_nothing + ... 'longlist', # list all lines + ... 'source do_something', # list all lines of function + ... 'continue', + ... ]): + ... test_function() + > <doctest test.test_pdb.test_list_commands[1]>(3)test_function() + -> ret = test_function_2('baz') + (Pdb) list + 1 def test_function(): + 2 import pdb; pdb.Pdb().set_trace() + 3 -> ret = test_function_2('baz') + [EOF] + (Pdb) step + --Call-- + > <doctest test.test_pdb.test_list_commands[0]>(1)test_function_2() + -> def test_function_2(foo): + (Pdb) list + 1 -> def test_function_2(foo): + 2 import test_pdb + 3 test_pdb.do_nothing() + 4 'some...' + 5 'more...' + 6 'code...' + 7 'to...' + 8 'make...' + 9 'a...' + 10 'long...' + 11 'listing...' + (Pdb) list + 12 'useful...' + 13 '...' + 14 '...' + 15 return foo + [EOF] + (Pdb) list 1,3 + 1 -> def test_function_2(foo): + 2 import test_pdb + 3 test_pdb.do_nothing() + (Pdb) list x + *** ... + (Pdb) next + > <doctest test.test_pdb.test_list_commands[0]>(2)test_function_2() + -> import test_pdb + (Pdb) next + > <doctest test.test_pdb.test_list_commands[0]>(3)test_function_2() + -> test_pdb.do_nothing() + (Pdb) step + --Call-- + > /home/gbr/devel/python/Lib/test/test_pdb.py(260)do_nothing() + -> def do_nothing(): + (Pdb) longlist + ... -> def do_nothing(): + ... pass + (Pdb) source do_something + ... def do_something(): + ... print(42) + (Pdb) continue + """ + + def test_pdb_skip_modules(): """This illustrates the simple case of module skipping. |