From f64013105e7bbcff202934a3f5be779ffb07e89d Mon Sep 17 00:00:00 2001 From: Volker Braun Date: Sun, 30 Jul 2017 14:13:32 +0200 Subject: [PATCH] Enable print_function in doctests --- src/sage/doctest/forker.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/sage/doctest/forker.py b/src/sage/doctest/forker.py index 9a5d9822f12..8ae0bb2de5e 100644 --- a/src/sage/doctest/forker.py +++ b/src/sage/doctest/forker.py @@ -35,6 +35,7 @@ from __future__ import print_function from __future__ import absolute_import +import __future__ import hashlib, multiprocessing, os, sys, time, warnings, signal, linecache import doctest, traceback @@ -45,7 +46,11 @@ from .parsing import OriginalSource, reduce_hex from sage.structure.sage_object import SageObject from .parsing import SageOutputChecker, pre_hash, get_source -from sage.repl.user_globals import set_globals +from sage.repl.user_globals import set_globals, get_globals + + +# All doctests run as if the following future imports are present +MANDATORY_COMPILE_FLAGS = __future__.print_function.compiler_flag def init_sage(): @@ -130,6 +135,7 @@ def init_sage(): stringPict.terminal_width = lambda self:0 + def showwarning_with_traceback(message, category, filename, lineno, file=sys.stdout, line=None): r""" Displays a warning message with a traceback. @@ -624,6 +630,7 @@ def run(self, test, compileflags=None, out=None, clear_globs=True): self.test = test if compileflags is None: compileflags = doctest._extract_future_flags(test.globs) + compileflags |= MANDATORY_COMPILE_FLAGS # We use this slightly modified version of Pdb because it # interacts better with the doctesting framework (like allowing # doctests for sys.settrace()). Since we already have output