summaryrefslogtreecommitdiffstats
path: root/Lib/doctest.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-07-30 09:23:23 (GMT)
committerGeorg Brandl <georg@python.org>2010-07-30 09:23:23 (GMT)
commit25fbb891d86ecea80d7f12d49a8aa298b9312efa (patch)
tree6c3011a866a9f4c96cee0f4b2f15f8c9ae1615d0 /Lib/doctest.py
parent46b9afc862974e5855f0ca8a181096945483c86e (diff)
downloadcpython-25fbb891d86ecea80d7f12d49a8aa298b9312efa.zip
cpython-25fbb891d86ecea80d7f12d49a8aa298b9312efa.tar.gz
cpython-25fbb891d86ecea80d7f12d49a8aa298b9312efa.tar.bz2
Issue #8048: Prevent doctests from failing when sys.displayhook has
been reassigned.
Diffstat (limited to 'Lib/doctest.py')
-rw-r--r--Lib/doctest.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/doctest.py b/Lib/doctest.py
index 5111a73..0db75b4 100644
--- a/Lib/doctest.py
+++ b/Lib/doctest.py
@@ -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