Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
2e0c83c8
Commit
2e0c83c8
authored
Aug 09, 2004
by
Tim Peters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Edward's latest checkins somehow managed to wipe out my previous latest
checkins. Reapplying the latter changes.
parent
954e266a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
15 deletions
+17
-15
Lib/doctest.py
Lib/doctest.py
+17
-14
Lib/test/test_doctest.py
Lib/test/test_doctest.py
+0
-1
No files found.
Lib/doctest.py
View file @
2e0c83c8
...
@@ -1259,27 +1259,30 @@ class DocTestRunner:
...
@@ -1259,27 +1259,30 @@ class DocTestRunner:
if
compileflags
is
None
:
if
compileflags
is
None
:
compileflags
=
_extract_future_flags
(
test
.
globs
)
compileflags
=
_extract_future_flags
(
test
.
globs
)
save_stdout
=
sys
.
stdout
if
out
is
None
:
if
out
is
None
:
out
=
sys
.
stdout
.
write
out
=
save_stdout
.
write
saveout
=
sys
.
stdout
sys
.
stdout
=
self
.
_fakeout
# Note that don't save away the previous pdb.set_trace. Rather,
# Patch pdb.set_trace to restore sys.stdout, so that interactive
# we safe pdb.set_trace on import (see import section above).
# debugging output is visible (not still redirected to self._fakeout).
# We then call and restore that original cersion. We do it this
# Note that we run "the real" pdb.set_trace (captured at doctest
# way to make this feature testable. If we kept and called the
# import time) in our replacement. Because the current run() may
# previous version, we'd end up restoring the original stdout,
# run another doctest (and so on), the current pdb.set_trace may be
# which is not what we want.
# our set_trace function, which changes sys.stdout. If we called
# a chain of those, we wouldn't be left with the save_stdout
# *this* run() invocation wants.
def
set_trace
():
def
set_trace
():
sys
.
stdout
=
saveout
sys
.
stdout
=
save
_std
out
real_pdb_set_trace
()
real_pdb_set_trace
()
save_set_trace
=
pdb
.
set_trace
pdb
.
set_trace
=
set_trace
try
:
try
:
sys
.
stdout
=
self
.
_fakeout
pdb
.
set_trace
=
set_trace
return
self
.
__run
(
test
,
compileflags
,
out
)
return
self
.
__run
(
test
,
compileflags
,
out
)
finally
:
finally
:
sys
.
stdout
=
saveout
sys
.
stdout
=
save
_std
out
pdb
.
set_trace
=
real_pdb
_set_trace
pdb
.
set_trace
=
save
_set_trace
if
clear_globs
:
if
clear_globs
:
test
.
globs
.
clear
()
test
.
globs
.
clear
()
...
...
Lib/test/test_doctest.py
View file @
2e0c83c8
...
@@ -1044,7 +1044,6 @@ def test_pdb_set_trace():
...
@@ -1044,7 +1044,6 @@ def test_pdb_set_trace():
... >>> calls_set_trace()
... >>> calls_set_trace()
... '''
... '''
>>> test = parser.get_doctest(doc, globals(), "foo", "foo.py", 0)
>>> test = parser.get_doctest(doc, globals(), "foo", "foo.py", 0)
>>> fake_stdin = tempfile.TemporaryFile(mode='w+')
>>> fake_stdin = tempfile.TemporaryFile(mode='w+')
>>> fake_stdin.write('\n'.join([
>>> fake_stdin.write('\n'.join([
... 'up', # up out of pdb.set_trace
... 'up', # up out of pdb.set_trace
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment