Skip to content

Commit 075cff7

Browse files
committed
Make doctest output compatible with old and new IPython
1 parent dc931ea commit 075cff7

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/sage/repl/ipython_extension.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@
6464
sage: shell.quit()
6565
"""
6666

67-
from IPython.core.magic import Magics, magics_class, line_magic, cell_magic
6867
from IPython.core.display import HTML
6968
from IPython.core.getipython import get_ipython
69+
from IPython.core.magic import Magics, cell_magic, line_magic, magics_class
7070

71-
from sage.repl.load import load_wrap
7271
from sage.env import SAGE_IMPORTALL, SAGE_STARTUP_FILE
7372
from sage.misc.lazy_import import LazyImport
7473
from sage.misc.misc import run_once
74+
from sage.repl.load import load_wrap
7575

7676

7777
def _running_in_notebook():
@@ -321,7 +321,7 @@ def display(self, args):
321321
if max_width <= 0:
322322
raise ValueError(
323323
"max width must be a positive integer")
324-
import sage.typeset.character_art as character_art
324+
from sage.typeset import character_art
325325
character_art.MAX_WIDTH = max_width
326326
dm.preferences.text = arg0
327327
# Unset all
@@ -478,9 +478,10 @@ def cython(self, line, cell):
478478
...
479479
ValueError: No closing quotation
480480
"""
481-
from sage.misc.cython import cython_compile
482-
import shlex
483481
import argparse
482+
import shlex
483+
484+
from sage.misc.cython import cython_compile
484485

485486
class ExitCatchingArgumentParser(argparse.ArgumentParser):
486487
def error(self, message):
@@ -665,7 +666,7 @@ def init_line_transforms(self):
665666
sage: ip.input_transformer_manager.check_complete(''' # indirect doctest
666667
....: for i in [1 .. 2]:
667668
....: a = 2''')
668-
('incomplete', 2)
669+
('incomplete', ...)
669670
sage: ip.input_transformer_manager.check_complete('''
670671
....: def foo(L)
671672
....: K.<a> = L''')
@@ -701,7 +702,8 @@ def init_line_transforms(self):
701702
('incomplete', 4)
702703
"""
703704
from IPython.core.inputtransformer2 import TransformerManager
704-
from .interpreter import SagePromptTransformer, SagePreparseTransformer
705+
706+
from sage.repl.interpreter import SagePreparseTransformer, SagePromptTransformer
705707

706708
self.shell.input_transformer_manager.cleanup_transforms.insert(1, SagePromptTransformer)
707709
self.shell.input_transformers_post.append(SagePreparseTransformer)

0 commit comments

Comments
 (0)