mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Issue #8048: Prevent doctests from failing when sys.displayhook has
been reassigned.
This commit is contained in:
parent
46b9afc862
commit
25fbb891d8
3 changed files with 37 additions and 0 deletions
|
@ -1379,12 +1379,17 @@ class DocTestRunner:
|
|||
self.save_linecache_getlines = linecache.getlines
|
||||
linecache.getlines = self.__patched_linecache_getlines
|
||||
|
||||
# Make sure sys.displayhook just prints the value to stdout
|
||||
save_displayhook = sys.displayhook
|
||||
sys.displayhook = sys.__displayhook__
|
||||
|
||||
try:
|
||||
return self.__run(test, compileflags, out)
|
||||
finally:
|
||||
sys.stdout = save_stdout
|
||||
pdb.set_trace = save_set_trace
|
||||
linecache.getlines = self.save_linecache_getlines
|
||||
sys.displayhook = save_displayhook
|
||||
if clear_globs:
|
||||
test.globs.clear()
|
||||
import builtins
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue