From 25fbb891d86ecea80d7f12d49a8aa298b9312efa Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Fri, 30 Jul 2010 09:23:23 +0000 Subject: Issue #8048: Prevent doctests from failing when sys.displayhook has been reassigned. --- Lib/doctest.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Lib/doctest.py') diff --git a/Lib/doctest.py b/Lib/doctest.py index 5111a732e5..0db75b4343 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 -- cgit v1.2.1