mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
This started as a spelling and whitespace cleanup. The comment for
the set_trace fiddling didn't make sense to me, and I ended up reworking that part of the code. We really do want to save and restore pdb.set_trace, so that each dynamically nested level of doctest gets sys.stdout fiddled to what's appropriate for *it*. The only "trick" really needed is that these layers of set_trace wrappers each call the original pdb.set_trace (instead of the current pdb.set_trace).
This commit is contained in:
parent
0d2a75c7b8
commit
413ced6c22
2 changed files with 21 additions and 19 deletions
|
@ -987,11 +987,11 @@ Run the debugger on the docstring, and then restore sys.stdin.
|
|||
def test_pdb_set_trace():
|
||||
r"""Using pdb.set_trace from a doctest
|
||||
|
||||
You can use pdb.set_trace from a doctest. To do so, you must
|
||||
You can use pdb.set_trace from a doctest. To do so, you must
|
||||
retrieve the set_trace function from the pdb module at the time
|
||||
you use it. The doctest module changes sys,stdout so that it can
|
||||
capture program output. It also temporarily replaces pdb.set_trace
|
||||
with a version that restores stdout. This is necessary for you to
|
||||
you use it. The doctest module changes sys.stdout so that it can
|
||||
capture program output. It also temporarily replaces pdb.set_trace
|
||||
with a version that restores stdout. This is necessary for you to
|
||||
see debugger output.
|
||||
|
||||
>>> doc = '''
|
||||
|
@ -1041,8 +1041,7 @@ def test_pdb_set_trace():
|
|||
... >>> calls_set_trace()
|
||||
... '''
|
||||
>>> test = doctest.DocTest(doc, globals(), "foo", "foo.py", 0)
|
||||
|
||||
>>> import tempfile
|
||||
|
||||
>>> fake_stdin = tempfile.TemporaryFile(mode='w+')
|
||||
>>> fake_stdin.write('\n'.join([
|
||||
... 'up', # up out of pdb.set_trace
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue