Skip to content

Commit

Permalink
sagemathgh-39616: Fix tests with IPython 9
Browse files Browse the repository at this point in the history
IPython 9 works fine with Sage at runtime but breaks some tests:

- `NoColor` should be lowercase now and throws a warning otherwise https
://github.com/ipython/ipython/commit/a796b952038faa904c5d7e5ea6c068b17e7
65790
- `input_transformer_manager.check_complete` returning two spaces
indentation was a bug caused by the `# indirect doctest` tag, which
confused the parser. This is fixed in IPython 9, we remove the `#
indirect doctest` so the test output is the same for all IPython
versions.
- Account for some addional verbosity in a couple of tests.

URL: sagemath#39616
Reported by: Antonio Rojas
Reviewer(s): François Bissey
  • Loading branch information
Release Manager committed Mar 2, 2025
2 parents 5894186 + c0ccd07 commit 7d88a83
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions build/pkgs/configure/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
tarball=configure-VERSION.tar.gz
sha1=e093bc99c7c72359d0ea6afd49046133607fe391
sha256=2d5d04f26068b2c8aafd1e3b69e23ae2788390846f779e5714df6856ce89cde1
sha1=320c7f8637d89bc1117db5bf3a7e743add1b0dd3
sha256=ee7d7c93b2fa3e1ceadeadcc82c3cce986b9e0f92282cec4fbbe273625edc306
2 changes: 1 addition & 1 deletion build/pkgs/configure/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
77c4e9b745daab99cdc0e2e989515a6f4ec91ed9
420a4bbd03606f09a9019208beda60255ed5643f
2 changes: 1 addition & 1 deletion src/sage/doctest/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@
s...: a = 3
s...: b = 5
s...: a + b
8
8...
sage:
<BLANKLINE>
Returning to doctests...
Expand Down
5 changes: 3 additions & 2 deletions src/sage/repl/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def colors(self):
"""
Return the IPython color palette.
This returns ``'NoColor'`` during doctests to avoid ANSI escape
This returns ``'nocolor'`` during doctests to avoid ANSI escape
sequences.
EXAMPLES::
Expand All @@ -82,7 +82,8 @@ def colors(self):
True
"""
if not self._allow_ansi():
return 'NoColor'
from IPython import version_info
return 'nocolor' if version_info[0] >= 9 else 'NoColor'
from sage.repl.interpreter import SageTerminalInteractiveShell
return SageTerminalInteractiveShell.colors.default()

Expand Down
4 changes: 2 additions & 2 deletions src/sage/repl/ipython_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,10 +662,10 @@ def init_line_transforms(self):
sage: from IPython import get_ipython
sage: ip = get_ipython()
sage: ip.input_transformer_manager.check_complete(''' # indirect doctest
sage: ip.input_transformer_manager.check_complete('''
....: for i in [1 .. 2]:
....: a = 2''')
('incomplete', 2)
('incomplete', 4)
sage: ip.input_transformer_manager.check_complete('''
....: def foo(L)
....: K.<a> = L''')
Expand Down
2 changes: 1 addition & 1 deletion src/sage/tests/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def test_executable(args, input='', timeout=100.0, pydebug_ignore_warnings=False
4
**********************************************************************
Previously executed commands:
s...: assert True is False
s...: assert True is False...
sage:
<BLANKLINE>
Returning to doctests...
Expand Down

0 comments on commit 7d88a83

Please # to comment.