Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix tests with IPython 9 #39616

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/sage/doctest/forker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1489,6 +1489,7 @@
from sage.repl.configuration import sage_ipython_config
from IPython.terminal.embed import InteractiveShellEmbed
cfg = sage_ipython_config.default()
cfg.InteractiveShell.enable_tip = False

Check warning on line 1492 in src/sage/doctest/forker.py

View check run for this annotation

Codecov / codecov/patch

src/sage/doctest/forker.py#L1492

Added line #L1492 was not covered by tests
# Currently this doesn't work: prompts only work in pty
# We keep simple_prompt=True, prompts will be "In [0]:"
# cfg.InteractiveShell.prompts_class = DebugPrompts
Expand Down Expand Up @@ -2192,7 +2193,7 @@
sage: W.start()
sage: DC = DocTestController(DD, filename)
sage: reporter = DocTestReporter(DC)
sage: W.join() # Wait for worker to finish

Check warning on line 2196 in src/sage/doctest/forker.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12)

Warning: slow doctest:

slow doctest:

Check warning on line 2196 in src/sage/doctest/forker.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.11)

Warning: slow doctest:

slow doctest:
sage: result = W.result_queue.get()
sage: reporter.report(FDS, False, W.exitcode, result, "")
[... tests, ...s wall]
Expand Down Expand Up @@ -2319,7 +2320,7 @@
....: except OSError:
....: print("Write end of pipe successfully closed")
Write end of pipe successfully closed
sage: W.join() # Wait for worker to finish

Check warning on line 2323 in src/sage/doctest/forker.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12)

Warning: slow doctest:

slow doctest:

Check warning on line 2323 in src/sage/doctest/forker.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.11)

Warning: slow doctest:

slow doctest:
"""
super().start()

Expand Down Expand Up @@ -2355,7 +2356,7 @@
sage: W.start()
sage: while W.rmessages is not None:
....: W.read_messages()
sage: W.join()

Check warning on line 2359 in src/sage/doctest/forker.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12)

Warning: slow doctest:

slow doctest:

Check warning on line 2359 in src/sage/doctest/forker.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.11)

Warning: slow doctest:

slow doctest:
sage: len(W.messages) > 0
True
"""
Expand Down Expand Up @@ -2387,7 +2388,7 @@
sage: FDS = FileDocTestSource(filename, DD)
sage: W = DocTestWorker(FDS, DD)
sage: W.start()
sage: W.join()

Check warning on line 2391 in src/sage/doctest/forker.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12)

Warning: slow doctest:

slow doctest:

Check warning on line 2391 in src/sage/doctest/forker.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.11)

Warning: slow doctest:

slow doctest:
sage: W.save_result_output()
sage: sorted(W.result[1].keys())
['cputime', 'err', 'failures', 'optionals', 'tests', 'walltime', 'walltime_skips']
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
Loading