diff options
author | Georg Brandl <georg@python.org> | 2010-07-30 18:46:38 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2010-07-30 18:46:38 (GMT) |
commit | 0a9c3e91dc50ce22a48ff7364a6c297ffb91c19a (patch) | |
tree | cfbc1e378c95a70e7d07167ae0c985572a524ad4 /Lib/test/test_pdb.py | |
parent | cdf66a9a7c6fe761353058d6d8eb3695ac567722 (diff) | |
download | cpython-0a9c3e91dc50ce22a48ff7364a6c297ffb91c19a.zip cpython-0a9c3e91dc50ce22a48ff7364a6c297ffb91c19a.tar.gz cpython-0a9c3e91dc50ce22a48ff7364a6c297ffb91c19a.tar.bz2 |
Show the traceback line numbers as well as the current line numbers if an exception is being debugged. Courtesy of pdb++ by Antonio Cuni. Also document -> and >> markers for "list".
Diffstat (limited to 'Lib/test/test_pdb.py')
-rw-r--r-- | Lib/test/test_pdb.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py index 0861e1e..6010bf3 100644 --- a/Lib/test/test_pdb.py +++ b/Lib/test/test_pdb.py @@ -359,6 +359,68 @@ def test_list_commands(): """ +def test_post_mortem(): + """Test post mortem traceback debugging. + + >>> def test_function_2(): + ... try: + ... 1/0 + ... finally: + ... print('Exception!') + + >>> def test_function(): + ... import pdb; pdb.Pdb().set_trace() + ... test_function_2() + ... print('Not reached.') + + >>> with PdbTestInput([ # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE + ... 'next', # step over exception-raising call + ... 'bt', # get a backtrace + ... 'list', # list code of test_function() + ... 'down', # step into test_function_2() + ... 'list', # list code of test_function_2() + ... 'continue', + ... ]): + ... try: + ... test_function() + ... except ZeroDivisionError: + ... print('Correctly reraised.') + > <doctest test.test_pdb.test_post_mortem[1]>(3)test_function() + -> test_function_2() + (Pdb) next + Exception! + ZeroDivisionError: division by zero + > <doctest test.test_pdb.test_post_mortem[1]>(3)test_function() + -> test_function_2() + (Pdb) bt + ... + <doctest test.test_pdb.test_post_mortem[2]>(10)<module>() + -> test_function() + > <doctest test.test_pdb.test_post_mortem[1]>(3)test_function() + -> test_function_2() + <doctest test.test_pdb.test_post_mortem[0]>(3)test_function_2() + -> 1/0 + (Pdb) list + 1 def test_function(): + 2 import pdb; pdb.Pdb().set_trace() + 3 -> test_function_2() + 4 print('Not reached.') + [EOF] + (Pdb) down + > <doctest test.test_pdb.test_post_mortem[0]>(3)test_function_2() + -> 1/0 + (Pdb) list + 1 def test_function_2(): + 2 try: + 3 >> 1/0 + 4 finally: + 5 -> print('Exception!') + [EOF] + (Pdb) continue + Correctly reraised. + """ + + def test_pdb_skip_modules(): """This illustrates the simple case of module skipping. |