Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_pdb.py @ 79675:c0a2294de787 2.7
Issue #16199: Backport 2to3 typo fix from 3.2.
| author | Chris Jerdonek <chris.jerdonek@gmail.com> |
|---|---|
| date | Thu, 11 Oct 2012 16:15:46 -0700 |
| parents | 2644e4ea02d3 |
| children |
| rev | line source |
|---|---|
|
53776
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
1 # A test suite for pdb; at the moment, this only validates skipping of |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
2 # specified test modules (RFE #5142). |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
3 |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
4 import imp |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
5 import sys |
|
73601
f7dd5178f36a
PDB now will properly escape backslashes in the names of modules it executes. Fixes #7750
Jason R. Coombs <jaraco@jaraco.com>
parents:
66536
diff
changeset
|
6 import os |
|
f7dd5178f36a
PDB now will properly escape backslashes in the names of modules it executes. Fixes #7750
Jason R. Coombs <jaraco@jaraco.com>
parents:
66536
diff
changeset
|
7 import unittest |
|
f7dd5178f36a
PDB now will properly escape backslashes in the names of modules it executes. Fixes #7750
Jason R. Coombs <jaraco@jaraco.com>
parents:
66536
diff
changeset
|
8 import subprocess |
|
76677
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
9 import textwrap |
|
53776
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
10 |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
11 from test import test_support |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
12 # This little helper class is essential for testing pdb under doctest. |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
13 from test_doctest import _FakeInput |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
14 |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
15 |
|
76677
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
16 class PdbTestCase(unittest.TestCase): |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
17 |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
18 def run_pdb(self, script, commands): |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
19 """Run 'script' lines with pdb and the pdb 'commands'.""" |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
20 filename = 'main.py' |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
21 with open(filename, 'w') as f: |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
22 f.write(textwrap.dedent(script)) |
|
76783
2644e4ea02d3
#13183: backport fixes to test_pdb to 2.7 branch
Georg Brandl <georg@python.org>
parents:
76708
diff
changeset
|
23 self.addCleanup(test_support.unlink, filename) |
|
76677
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
24 cmd = [sys.executable, '-m', 'pdb', filename] |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
25 stdout = stderr = None |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
26 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
27 stdin=subprocess.PIPE, |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
28 stderr=subprocess.STDOUT, |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
29 ) |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
30 stdout, stderr = proc.communicate(commands) |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
31 proc.stdout.close() |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
32 proc.stdin.close() |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
33 return stdout, stderr |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
34 |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
35 def test_issue13183(self): |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
36 script = """ |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
37 from bar import bar |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
38 |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
39 def foo(): |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
40 bar() |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
41 |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
42 def nope(): |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
43 pass |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
44 |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
45 def foobar(): |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
46 foo() |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
47 nope() |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
48 |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
49 foobar() |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
50 """ |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
51 commands = """ |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
52 from bar import bar |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
53 break bar |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
54 continue |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
55 step |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
56 step |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
57 quit |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
58 """ |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
59 bar = """ |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
60 def bar(): |
|
76708
3b2aa777b725
fix windows test failure - issue13183
Senthil Kumaran <senthil@uthcode.com>
parents:
76677
diff
changeset
|
61 pass |
|
76677
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
62 """ |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
63 with open('bar.py', 'w') as f: |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
64 f.write(textwrap.dedent(bar)) |
|
76783
2644e4ea02d3
#13183: backport fixes to test_pdb to 2.7 branch
Georg Brandl <georg@python.org>
parents:
76708
diff
changeset
|
65 self.addCleanup(test_support.unlink, 'bar.py') |
|
76677
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
66 stdout, stderr = self.run_pdb(script, commands) |
|
76783
2644e4ea02d3
#13183: backport fixes to test_pdb to 2.7 branch
Georg Brandl <georg@python.org>
parents:
76708
diff
changeset
|
67 self.assertTrue( |
|
2644e4ea02d3
#13183: backport fixes to test_pdb to 2.7 branch
Georg Brandl <georg@python.org>
parents:
76708
diff
changeset
|
68 any('main.py(5)foo()->None' in l for l in stdout.splitlines()), |
|
2644e4ea02d3
#13183: backport fixes to test_pdb to 2.7 branch
Georg Brandl <georg@python.org>
parents:
76708
diff
changeset
|
69 'Fail to step into the caller after a return') |
|
76677
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
70 |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
71 |
|
56004
32448f8a6c63
Remove some more boilerplate from the actual tests in test_pdb.
Georg Brandl <georg@python.org>
parents:
53776
diff
changeset
|
72 class PdbTestInput(object): |
|
32448f8a6c63
Remove some more boilerplate from the actual tests in test_pdb.
Georg Brandl <georg@python.org>
parents:
53776
diff
changeset
|
73 """Context manager that makes testing Pdb in doctests easier.""" |
|
32448f8a6c63
Remove some more boilerplate from the actual tests in test_pdb.
Georg Brandl <georg@python.org>
parents:
53776
diff
changeset
|
74 |
|
32448f8a6c63
Remove some more boilerplate from the actual tests in test_pdb.
Georg Brandl <georg@python.org>
parents:
53776
diff
changeset
|
75 def __init__(self, input): |
|
32448f8a6c63
Remove some more boilerplate from the actual tests in test_pdb.
Georg Brandl <georg@python.org>
parents:
53776
diff
changeset
|
76 self.input = input |
|
32448f8a6c63
Remove some more boilerplate from the actual tests in test_pdb.
Georg Brandl <georg@python.org>
parents:
53776
diff
changeset
|
77 |
|
32448f8a6c63
Remove some more boilerplate from the actual tests in test_pdb.
Georg Brandl <georg@python.org>
parents:
53776
diff
changeset
|
78 def __enter__(self): |
|
32448f8a6c63
Remove some more boilerplate from the actual tests in test_pdb.
Georg Brandl <georg@python.org>
parents:
53776
diff
changeset
|
79 self.real_stdin = sys.stdin |
|
32448f8a6c63
Remove some more boilerplate from the actual tests in test_pdb.
Georg Brandl <georg@python.org>
parents:
53776
diff
changeset
|
80 sys.stdin = _FakeInput(self.input) |
|
32448f8a6c63
Remove some more boilerplate from the actual tests in test_pdb.
Georg Brandl <georg@python.org>
parents:
53776
diff
changeset
|
81 |
|
32448f8a6c63
Remove some more boilerplate from the actual tests in test_pdb.
Georg Brandl <georg@python.org>
parents:
53776
diff
changeset
|
82 def __exit__(self, *exc): |
|
32448f8a6c63
Remove some more boilerplate from the actual tests in test_pdb.
Georg Brandl <georg@python.org>
parents:
53776
diff
changeset
|
83 sys.stdin = self.real_stdin |
|
32448f8a6c63
Remove some more boilerplate from the actual tests in test_pdb.
Georg Brandl <georg@python.org>
parents:
53776
diff
changeset
|
84 |
|
32448f8a6c63
Remove some more boilerplate from the actual tests in test_pdb.
Georg Brandl <georg@python.org>
parents:
53776
diff
changeset
|
85 |
|
56005
7a3ed1b43410
Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that.
Georg Brandl <georg@python.org>
parents:
56004
diff
changeset
|
86 def write(x): |
|
7a3ed1b43410
Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that.
Georg Brandl <georg@python.org>
parents:
56004
diff
changeset
|
87 print x |
|
7a3ed1b43410
Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that.
Georg Brandl <georg@python.org>
parents:
56004
diff
changeset
|
88 |
|
7a3ed1b43410
Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that.
Georg Brandl <georg@python.org>
parents:
56004
diff
changeset
|
89 def test_pdb_displayhook(): |
|
7a3ed1b43410
Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that.
Georg Brandl <georg@python.org>
parents:
56004
diff
changeset
|
90 """This tests the custom displayhook for pdb. |
|
7a3ed1b43410
Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that.
Georg Brandl <georg@python.org>
parents:
56004
diff
changeset
|
91 |
|
7a3ed1b43410
Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that.
Georg Brandl <georg@python.org>
parents:
56004
diff
changeset
|
92 >>> def test_function(foo, bar): |
|
7a3ed1b43410
Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that.
Georg Brandl <georg@python.org>
parents:
56004
diff
changeset
|
93 ... import pdb; pdb.Pdb().set_trace() |
|
7a3ed1b43410
Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that.
Georg Brandl <georg@python.org>
parents:
56004
diff
changeset
|
94 ... pass |
|
7a3ed1b43410
Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that.
Georg Brandl <georg@python.org>
parents:
56004
diff
changeset
|
95 |
|
7a3ed1b43410
Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that.
Georg Brandl <georg@python.org>
parents:
56004
diff
changeset
|
96 >>> with PdbTestInput([ |
|
7a3ed1b43410
Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that.
Georg Brandl <georg@python.org>
parents:
56004
diff
changeset
|
97 ... 'foo', |
|
7a3ed1b43410
Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that.
Georg Brandl <georg@python.org>
parents:
56004
diff
changeset
|
98 ... 'bar', |
|
7a3ed1b43410
Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that.
Georg Brandl <georg@python.org>
parents:
56004
diff
changeset
|
99 ... 'for i in range(5): write(i)', |
|
7a3ed1b43410
Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that.
Georg Brandl <georg@python.org>
parents:
56004
diff
changeset
|
100 ... 'continue', |
|
7a3ed1b43410
Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that.
Georg Brandl <georg@python.org>
parents:
56004
diff
changeset
|
101 ... ]): |
|
7a3ed1b43410
Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that.
Georg Brandl <georg@python.org>
parents:
56004
diff
changeset
|
102 ... test_function(1, None) |
|
7a3ed1b43410
Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that.
Georg Brandl <georg@python.org>
parents:
56004
diff
changeset
|
103 > <doctest test.test_pdb.test_pdb_displayhook[0]>(3)test_function() |
|
7a3ed1b43410
Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that.
Georg Brandl <georg@python.org>
parents:
56004
diff
changeset
|
104 -> pass |
|
7a3ed1b43410
Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that.
Georg Brandl <georg@python.org>
parents:
56004
diff
changeset
|
105 (Pdb) foo |
|
7a3ed1b43410
Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that.
Georg Brandl <georg@python.org>
parents:
56004
diff
changeset
|
106 1 |
|
7a3ed1b43410
Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that.
Georg Brandl <georg@python.org>
parents:
56004
diff
changeset
|
107 (Pdb) bar |
|
7a3ed1b43410
Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that.
Georg Brandl <georg@python.org>
parents:
56004
diff
changeset
|
108 (Pdb) for i in range(5): write(i) |
|
7a3ed1b43410
Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that.
Georg Brandl <georg@python.org>
parents:
56004
diff
changeset
|
109 0 |
|
7a3ed1b43410
Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that.
Georg Brandl <georg@python.org>
parents:
56004
diff
changeset
|
110 1 |
|
7a3ed1b43410
Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that.
Georg Brandl <georg@python.org>
parents:
56004
diff
changeset
|
111 2 |
|
7a3ed1b43410
Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that.
Georg Brandl <georg@python.org>
parents:
56004
diff
changeset
|
112 3 |
|
7a3ed1b43410
Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that.
Georg Brandl <georg@python.org>
parents:
56004
diff
changeset
|
113 4 |
|
7a3ed1b43410
Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that.
Georg Brandl <georg@python.org>
parents:
56004
diff
changeset
|
114 (Pdb) continue |
|
7a3ed1b43410
Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that.
Georg Brandl <georg@python.org>
parents:
56004
diff
changeset
|
115 """ |
|
7a3ed1b43410
Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that.
Georg Brandl <georg@python.org>
parents:
56004
diff
changeset
|
116 |
|
66536
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
117 def test_pdb_breakpoint_commands(): |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
118 """Test basic commands related to breakpoints. |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
119 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
120 >>> def test_function(): |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
121 ... import pdb; pdb.Pdb().set_trace() |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
122 ... print(1) |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
123 ... print(2) |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
124 ... print(3) |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
125 ... print(4) |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
126 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
127 First, need to clear bdb state that might be left over from previous tests. |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
128 Otherwise, the new breakpoints might get assigned different numbers. |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
129 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
130 >>> from bdb import Breakpoint |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
131 >>> Breakpoint.next = 1 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
132 >>> Breakpoint.bplist = {} |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
133 >>> Breakpoint.bpbynumber = [None] |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
134 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
135 Now test the breakpoint commands. NORMALIZE_WHITESPACE is needed because |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
136 the breakpoint list outputs a tab for the "stop only" and "ignore next" |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
137 lines, which we don't want to put in here. |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
138 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
139 >>> with PdbTestInput([ # doctest: +NORMALIZE_WHITESPACE |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
140 ... 'break 3', |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
141 ... 'disable 1', |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
142 ... 'ignore 1 10', |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
143 ... 'condition 1 1 < 2', |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
144 ... 'break 4', |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
145 ... 'break 4', |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
146 ... 'break', |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
147 ... 'clear 3', |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
148 ... 'break', |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
149 ... 'condition 1', |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
150 ... 'enable 1', |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
151 ... 'clear 1', |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
152 ... 'commands 2', |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
153 ... 'print 42', |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
154 ... 'end', |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
155 ... 'continue', # will stop at breakpoint 2 (line 4) |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
156 ... 'clear', # clear all! |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
157 ... 'y', |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
158 ... 'tbreak 5', |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
159 ... 'continue', # will stop at temporary breakpoint |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
160 ... 'break', # make sure breakpoint is gone |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
161 ... 'continue', |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
162 ... ]): |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
163 ... test_function() |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
164 > <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>(3)test_function() |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
165 -> print(1) |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
166 (Pdb) break 3 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
167 Breakpoint 1 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:3 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
168 (Pdb) disable 1 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
169 (Pdb) ignore 1 10 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
170 Will ignore next 10 crossings of breakpoint 1. |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
171 (Pdb) condition 1 1 < 2 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
172 (Pdb) break 4 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
173 Breakpoint 2 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:4 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
174 (Pdb) break 4 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
175 Breakpoint 3 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:4 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
176 (Pdb) break |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
177 Num Type Disp Enb Where |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
178 1 breakpoint keep no at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:3 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
179 stop only if 1 < 2 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
180 ignore next 10 hits |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
181 2 breakpoint keep yes at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:4 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
182 3 breakpoint keep yes at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:4 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
183 (Pdb) clear 3 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
184 Deleted breakpoint 3 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
185 (Pdb) break |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
186 Num Type Disp Enb Where |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
187 1 breakpoint keep no at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:3 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
188 stop only if 1 < 2 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
189 ignore next 10 hits |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
190 2 breakpoint keep yes at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:4 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
191 (Pdb) condition 1 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
192 Breakpoint 1 is now unconditional. |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
193 (Pdb) enable 1 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
194 (Pdb) clear 1 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
195 Deleted breakpoint 1 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
196 (Pdb) commands 2 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
197 (com) print 42 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
198 (com) end |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
199 (Pdb) continue |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
200 1 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
201 42 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
202 > <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>(4)test_function() |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
203 -> print(2) |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
204 (Pdb) clear |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
205 Clear all breaks? y |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
206 (Pdb) tbreak 5 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
207 Breakpoint 4 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:5 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
208 (Pdb) continue |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
209 2 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
210 Deleted breakpoint 4 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
211 > <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>(5)test_function() |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
212 -> print(3) |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
213 (Pdb) break |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
214 (Pdb) continue |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
215 3 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
216 4 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
217 """ |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
218 |
|
56005
7a3ed1b43410
Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that.
Georg Brandl <georg@python.org>
parents:
56004
diff
changeset
|
219 |
|
53776
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
220 def test_pdb_skip_modules(): |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
221 """This illustrates the simple case of module skipping. |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
222 |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
223 >>> def skip_module(): |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
224 ... import string |
|
56004
32448f8a6c63
Remove some more boilerplate from the actual tests in test_pdb.
Georg Brandl <georg@python.org>
parents:
53776
diff
changeset
|
225 ... import pdb; pdb.Pdb(skip=['string*']).set_trace() |
|
53776
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
226 ... string.lower('FOO') |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
227 |
|
56004
32448f8a6c63
Remove some more boilerplate from the actual tests in test_pdb.
Georg Brandl <georg@python.org>
parents:
53776
diff
changeset
|
228 >>> with PdbTestInput([ |
|
32448f8a6c63
Remove some more boilerplate from the actual tests in test_pdb.
Georg Brandl <georg@python.org>
parents:
53776
diff
changeset
|
229 ... 'step', |
|
56005
7a3ed1b43410
Make the pdb displayhook compatible with the standard displayhook: do not print Nones. Add a test for that.
Georg Brandl <georg@python.org>
parents:
56004
diff
changeset
|
230 ... 'continue', |
|
56004
32448f8a6c63
Remove some more boilerplate from the actual tests in test_pdb.
Georg Brandl <georg@python.org>
parents:
53776
diff
changeset
|
231 ... ]): |
|
53776
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
232 ... skip_module() |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
233 > <doctest test.test_pdb.test_pdb_skip_modules[0]>(4)skip_module() |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
234 -> string.lower('FOO') |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
235 (Pdb) step |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
236 --Return-- |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
237 > <doctest test.test_pdb.test_pdb_skip_modules[0]>(4)skip_module()->None |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
238 -> string.lower('FOO') |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
239 (Pdb) continue |
|
56004
32448f8a6c63
Remove some more boilerplate from the actual tests in test_pdb.
Georg Brandl <georg@python.org>
parents:
53776
diff
changeset
|
240 """ |
|
53776
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
241 |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
242 |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
243 # Module for testing skipping of module that makes a callback |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
244 mod = imp.new_module('module_to_skip') |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
245 exec 'def foo_pony(callback): x = 1; callback(); return None' in mod.__dict__ |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
246 |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
247 |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
248 def test_pdb_skip_modules_with_callback(): |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
249 """This illustrates skipping of modules that call into other code. |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
250 |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
251 >>> def skip_module(): |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
252 ... def callback(): |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
253 ... return None |
|
56004
32448f8a6c63
Remove some more boilerplate from the actual tests in test_pdb.
Georg Brandl <georg@python.org>
parents:
53776
diff
changeset
|
254 ... import pdb; pdb.Pdb(skip=['module_to_skip*']).set_trace() |
|
53776
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
255 ... mod.foo_pony(callback) |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
256 |
|
56004
32448f8a6c63
Remove some more boilerplate from the actual tests in test_pdb.
Georg Brandl <georg@python.org>
parents:
53776
diff
changeset
|
257 >>> with PdbTestInput([ |
|
32448f8a6c63
Remove some more boilerplate from the actual tests in test_pdb.
Georg Brandl <georg@python.org>
parents:
53776
diff
changeset
|
258 ... 'step', |
|
32448f8a6c63
Remove some more boilerplate from the actual tests in test_pdb.
Georg Brandl <georg@python.org>
parents:
53776
diff
changeset
|
259 ... 'step', |
|
32448f8a6c63
Remove some more boilerplate from the actual tests in test_pdb.
Georg Brandl <georg@python.org>
parents:
53776
diff
changeset
|
260 ... 'step', |
|
32448f8a6c63
Remove some more boilerplate from the actual tests in test_pdb.
Georg Brandl <georg@python.org>
parents:
53776
diff
changeset
|
261 ... 'step', |
|
32448f8a6c63
Remove some more boilerplate from the actual tests in test_pdb.
Georg Brandl <georg@python.org>
parents:
53776
diff
changeset
|
262 ... 'step', |
|
32448f8a6c63
Remove some more boilerplate from the actual tests in test_pdb.
Georg Brandl <georg@python.org>
parents:
53776
diff
changeset
|
263 ... 'continue', |
|
32448f8a6c63
Remove some more boilerplate from the actual tests in test_pdb.
Georg Brandl <georg@python.org>
parents:
53776
diff
changeset
|
264 ... ]): |
|
53776
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
265 ... skip_module() |
|
56004
32448f8a6c63
Remove some more boilerplate from the actual tests in test_pdb.
Georg Brandl <georg@python.org>
parents:
53776
diff
changeset
|
266 ... pass # provides something to "step" to |
|
53776
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
267 > <doctest test.test_pdb.test_pdb_skip_modules_with_callback[0]>(5)skip_module() |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
268 -> mod.foo_pony(callback) |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
269 (Pdb) step |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
270 --Call-- |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
271 > <doctest test.test_pdb.test_pdb_skip_modules_with_callback[0]>(2)callback() |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
272 -> def callback(): |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
273 (Pdb) step |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
274 > <doctest test.test_pdb.test_pdb_skip_modules_with_callback[0]>(3)callback() |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
275 -> return None |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
276 (Pdb) step |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
277 --Return-- |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
278 > <doctest test.test_pdb.test_pdb_skip_modules_with_callback[0]>(3)callback()->None |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
279 -> return None |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
280 (Pdb) step |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
281 --Return-- |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
282 > <doctest test.test_pdb.test_pdb_skip_modules_with_callback[0]>(5)skip_module()->None |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
283 -> mod.foo_pony(callback) |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
284 (Pdb) step |
|
56004
32448f8a6c63
Remove some more boilerplate from the actual tests in test_pdb.
Georg Brandl <georg@python.org>
parents:
53776
diff
changeset
|
285 > <doctest test.test_pdb.test_pdb_skip_modules_with_callback[1]>(10)<module>() |
|
32448f8a6c63
Remove some more boilerplate from the actual tests in test_pdb.
Georg Brandl <georg@python.org>
parents:
53776
diff
changeset
|
286 -> pass # provides something to "step" to |
|
53776
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
287 (Pdb) continue |
|
56004
32448f8a6c63
Remove some more boilerplate from the actual tests in test_pdb.
Georg Brandl <georg@python.org>
parents:
53776
diff
changeset
|
288 """ |
|
53776
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
289 |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
290 |
|
63452
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
291 def test_pdb_continue_in_bottomframe(): |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
292 """Test that "continue" and "next" work properly in bottom frame (issue #5294). |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
293 |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
294 >>> def test_function(): |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
295 ... import pdb, sys; inst = pdb.Pdb() |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
296 ... inst.set_trace() |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
297 ... inst.botframe = sys._getframe() # hackery to get the right botframe |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
298 ... print(1) |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
299 ... print(2) |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
300 ... print(3) |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
301 ... print(4) |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
302 |
|
66536
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
303 First, need to clear bdb state that might be left over from previous tests. |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
304 Otherwise, the new breakpoints might get assigned different numbers. |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
305 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
306 >>> from bdb import Breakpoint |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
307 >>> Breakpoint.next = 1 |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
308 >>> Breakpoint.bplist = {} |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
309 >>> Breakpoint.bpbynumber = [None] |
|
8fd13c5d3882
Merged revisions 86861 via svnmerge from
Senthil Kumaran <orsenthil@gmail.com>
parents:
63452
diff
changeset
|
310 |
|
63452
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
311 >>> with PdbTestInput([ |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
312 ... 'next', |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
313 ... 'break 7', |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
314 ... 'continue', |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
315 ... 'next', |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
316 ... 'continue', |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
317 ... 'continue', |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
318 ... ]): |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
319 ... test_function() |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
320 > <doctest test.test_pdb.test_pdb_continue_in_bottomframe[0]>(4)test_function() |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
321 -> inst.botframe = sys._getframe() # hackery to get the right botframe |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
322 (Pdb) next |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
323 > <doctest test.test_pdb.test_pdb_continue_in_bottomframe[0]>(5)test_function() |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
324 -> print(1) |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
325 (Pdb) break 7 |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
326 Breakpoint 1 at <doctest test.test_pdb.test_pdb_continue_in_bottomframe[0]>:7 |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
327 (Pdb) continue |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
328 1 |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
329 2 |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
330 > <doctest test.test_pdb.test_pdb_continue_in_bottomframe[0]>(7)test_function() |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
331 -> print(3) |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
332 (Pdb) next |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
333 3 |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
334 > <doctest test.test_pdb.test_pdb_continue_in_bottomframe[0]>(8)test_function() |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
335 -> print(4) |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
336 (Pdb) continue |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
337 4 |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
338 """ |
|
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
339 |
|
73901
70337a6d5dde
Implemented suggested improvements for pdb test by Éric Araujo
Jason R. Coombs <jaraco@jaraco.com>
parents:
73601
diff
changeset
|
340 class ModuleInitTester(unittest.TestCase): |
|
73601
f7dd5178f36a
PDB now will properly escape backslashes in the names of modules it executes. Fixes #7750
Jason R. Coombs <jaraco@jaraco.com>
parents:
66536
diff
changeset
|
341 |
|
73901
70337a6d5dde
Implemented suggested improvements for pdb test by Éric Araujo
Jason R. Coombs <jaraco@jaraco.com>
parents:
73601
diff
changeset
|
342 def test_filename_correct(self): |
|
70337a6d5dde
Implemented suggested improvements for pdb test by Éric Araujo
Jason R. Coombs <jaraco@jaraco.com>
parents:
73601
diff
changeset
|
343 """ |
|
70337a6d5dde
Implemented suggested improvements for pdb test by Éric Araujo
Jason R. Coombs <jaraco@jaraco.com>
parents:
73601
diff
changeset
|
344 In issue 7750, it was found that if the filename has a sequence that |
|
70337a6d5dde
Implemented suggested improvements for pdb test by Éric Araujo
Jason R. Coombs <jaraco@jaraco.com>
parents:
73601
diff
changeset
|
345 resolves to an escape character in a Python string (such as \t), it |
|
70337a6d5dde
Implemented suggested improvements for pdb test by Éric Araujo
Jason R. Coombs <jaraco@jaraco.com>
parents:
73601
diff
changeset
|
346 will be treated as the escaped character. |
|
70337a6d5dde
Implemented suggested improvements for pdb test by Éric Araujo
Jason R. Coombs <jaraco@jaraco.com>
parents:
73601
diff
changeset
|
347 """ |
|
70337a6d5dde
Implemented suggested improvements for pdb test by Éric Araujo
Jason R. Coombs <jaraco@jaraco.com>
parents:
73601
diff
changeset
|
348 # the test_fn must contain something like \t |
|
70337a6d5dde
Implemented suggested improvements for pdb test by Éric Araujo
Jason R. Coombs <jaraco@jaraco.com>
parents:
73601
diff
changeset
|
349 # on Windows, this will create 'test_mod.py' in the current directory. |
|
70337a6d5dde
Implemented suggested improvements for pdb test by Éric Araujo
Jason R. Coombs <jaraco@jaraco.com>
parents:
73601
diff
changeset
|
350 # on Unix, this will create '.\test_mod.py' in the current directory. |
|
70337a6d5dde
Implemented suggested improvements for pdb test by Éric Araujo
Jason R. Coombs <jaraco@jaraco.com>
parents:
73601
diff
changeset
|
351 test_fn = '.\\test_mod.py' |
|
70337a6d5dde
Implemented suggested improvements for pdb test by Éric Araujo
Jason R. Coombs <jaraco@jaraco.com>
parents:
73601
diff
changeset
|
352 code = 'print("testing pdb")' |
|
70337a6d5dde
Implemented suggested improvements for pdb test by Éric Araujo
Jason R. Coombs <jaraco@jaraco.com>
parents:
73601
diff
changeset
|
353 with open(test_fn, 'w') as f: |
|
70337a6d5dde
Implemented suggested improvements for pdb test by Éric Araujo
Jason R. Coombs <jaraco@jaraco.com>
parents:
73601
diff
changeset
|
354 f.write(code) |
|
70337a6d5dde
Implemented suggested improvements for pdb test by Éric Araujo
Jason R. Coombs <jaraco@jaraco.com>
parents:
73601
diff
changeset
|
355 self.addCleanup(os.remove, test_fn) |
|
70337a6d5dde
Implemented suggested improvements for pdb test by Éric Araujo
Jason R. Coombs <jaraco@jaraco.com>
parents:
73601
diff
changeset
|
356 cmd = [sys.executable, '-m', 'pdb', test_fn,] |
|
73601
f7dd5178f36a
PDB now will properly escape backslashes in the names of modules it executes. Fixes #7750
Jason R. Coombs <jaraco@jaraco.com>
parents:
66536
diff
changeset
|
357 proc = subprocess.Popen(cmd, |
|
f7dd5178f36a
PDB now will properly escape backslashes in the names of modules it executes. Fixes #7750
Jason R. Coombs <jaraco@jaraco.com>
parents:
66536
diff
changeset
|
358 stdout=subprocess.PIPE, |
|
f7dd5178f36a
PDB now will properly escape backslashes in the names of modules it executes. Fixes #7750
Jason R. Coombs <jaraco@jaraco.com>
parents:
66536
diff
changeset
|
359 stdin=subprocess.PIPE, |
|
f7dd5178f36a
PDB now will properly escape backslashes in the names of modules it executes. Fixes #7750
Jason R. Coombs <jaraco@jaraco.com>
parents:
66536
diff
changeset
|
360 stderr=subprocess.STDOUT, |
|
f7dd5178f36a
PDB now will properly escape backslashes in the names of modules it executes. Fixes #7750
Jason R. Coombs <jaraco@jaraco.com>
parents:
66536
diff
changeset
|
361 ) |
|
f7dd5178f36a
PDB now will properly escape backslashes in the names of modules it executes. Fixes #7750
Jason R. Coombs <jaraco@jaraco.com>
parents:
66536
diff
changeset
|
362 stdout, stderr = proc.communicate('quit\n') |
|
73901
70337a6d5dde
Implemented suggested improvements for pdb test by Éric Araujo
Jason R. Coombs <jaraco@jaraco.com>
parents:
73601
diff
changeset
|
363 self.assertIn(code, stdout, "pdb munged the filename") |
|
73601
f7dd5178f36a
PDB now will properly escape backslashes in the names of modules it executes. Fixes #7750
Jason R. Coombs <jaraco@jaraco.com>
parents:
66536
diff
changeset
|
364 |
|
63452
3499ed6cbd07
Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from
Georg Brandl <georg@python.org>
parents:
63324
diff
changeset
|
365 |
|
53776
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
366 def test_main(): |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
367 from test import test_pdb |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
368 test_support.run_doctest(test_pdb, verbosity=True) |
|
76677
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
369 test_support.run_unittest( |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
370 PdbTestCase, |
|
5ea23739e9ba
issue13183 - Fix pdb skipping frames after hitting a breakpoint and running step. Patch by Xavier de Gaye
Senthil Kumaran <senthil@uthcode.com>
parents:
73901
diff
changeset
|
371 ModuleInitTester) |
|
53776
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
372 |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
373 if __name__ == '__main__': |
|
c49bc330327c
#5142: add module skipping feature to pdb.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
374 test_main() |
