Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPython 5.4 will need a minor change in Sage #23125

Closed
infinity0 mannequin opened this issue Jun 1, 2017 · 6 comments
Closed

IPython 5.4 will need a minor change in Sage #23125

infinity0 mannequin opened this issue Jun 1, 2017 · 6 comments

Comments

@infinity0
Copy link
Mannequin

infinity0 mannequin commented Jun 1, 2017

Due to ipython/ipython#10606 which was backported to IPython 5.4 and released yesterday, Sage's current doctests won't run against IPython 5.4. You'll need to apply this patch:

diff --git a/src/sage/interfaces/sage0.py b/src/sage/interfaces/sage0.py
index 56e6eba6c5..bcee80eaeb 100644
--- a/src/sage/interfaces/sage0.py
+++ b/src/sage/interfaces/sage0.py
@@ -160,7 +160,7 @@ class Sage(ExtraTabCompletion, Expect):
                 '--no-term-title',
                 '--simple-prompt',
             ])
-            prompt = re.compile('In \[\d+\]: ')
+            prompt = re.compile('sage: ') # needs to match SagePrompts
             if init_code is None:
                 init_code = ['from six.moves import cPickle']
 

It would be good to add some doctests, but I'm not sure what the best one would be. This works, but it feels a bit dirty to pass None to Prompt.__init__.

sage: from sage.repl.prompts import SagePrompts
sage: tokens = SagePrompts(None).in_prompt_tokens()
sage: prompt = "".join(x[1] for x in tokens)
sage: re.compile('sage: ').match(prompt)
<_sre.SRE_Match object at ...>

Upstream: None of the above - read trac for reasoning.

Component: interfaces

Keywords: ipython

Issue created by migration from https://trac.sagemath.org/ticket/23125

@infinity0 infinity0 mannequin added this to the sage-8.0 milestone Jun 1, 2017
@infinity0 infinity0 mannequin added c: interfaces labels Jun 1, 2017
@infinity0

This comment has been minimized.

@infinity0
Copy link
Mannequin Author

infinity0 mannequin commented Jun 1, 2017

comment:2

To clarify, a lot of doctests will run, but some will hang, including:

sage -t --long src/sage/misc/randstate.pyx  # Timed out
sage -t --long src/sage/interacts/debugger.py  # Timed out
sage -t --long src/sage/doctest/forker.py  # Timed out

and others.

@kiwifb
Copy link
Member

kiwifb commented Jun 2, 2017

comment:3

Thanks for the warning.

@infinity0
Copy link
Mannequin Author

infinity0 mannequin commented Jun 3, 2017

@kiwifb
Copy link
Member

kiwifb commented Sep 2, 2017

comment:5

I seem to have an extra doctest failure that I think is related to ipython 5.4

sage -t --long /usr/lib64/python2.7/site-packages/sage/doctest/forker.py
**********************************************************************
File "/usr/lib64/python2.7/site-packages/sage/doctest/forker.py", line 1123, in sage.doctest.forker.SageDocTestRunner.report_failure
Failed example:
    print(sage0.eval("sdf.init_sage(); DTR.run(DT, clear_globs=False)")) # indirect doctest
Expected:
    **********************************************************************
    Line 1, in doubling
    Failed example:
        2*a
    Expected:
        1
    Got:
        34
    **********************************************************************
    Previously executed commands:
    ...
Got:
    **********************************************************************
    Line 1, in doubling
    Failed example:
        2*a
    Expected:
        1
    Got:
        34
    **********************************************************************
    Previously executed commands:
**********************************************************************
File "/usr/lib64/python2.7/site-packages/sage/doctest/forker.py", line 1135, in sage.doctest.forker.SageDocTestRunner.report_failure
Failed example:
    sage0.eval("a")
Expected:
    '...17'
Got:
    ''
**********************************************************************
File "/usr/lib64/python2.7/site-packages/sage/doctest/forker.py", line 1137, in sage.doctest.forker.SageDocTestRunner.report_failure
Failed example:
    sage0.eval("quit")
Expected:
    'Returning to doctests...TestResults(failed=1, attempted=2)'
Got:
    '17'
**********************************************************************
1 item had failures:
   3 of  29 in sage.doctest.forker.SageDocTestRunner.report_failure
    [444 tests, 3 failures, 12.15 s]
----------------------------------------------------------------------
sage -t --long /usr/lib64/python2.7/site-packages/sage/doctest/forker.py  # 3 doctests failed
----------------------------------------------------------------------
Total time for all tests: 67.0 seconds
    cpu time: 2.7 seconds
    cumulative wall time: 12.1 seconds

@vbraun
Copy link
Member

vbraun commented Dec 17, 2017

comment:6

Dupe of #24389

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants