From e4ffe8e38c51a694cf5f8a43f48d8fb191b33d00 Mon Sep 17 00:00:00 2001 From: Antonio Rojas Date: Sat, 1 Mar 2025 23:05:46 +0100 Subject: [PATCH 1/3] Fix tests with IPython 9 --- src/sage/doctest/test.py | 2 +- src/sage/repl/ipython_extension.py | 4 ++-- src/sage/tests/cmdline.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sage/doctest/test.py b/src/sage/doctest/test.py index bbfa3acef01..d8c579c6ef3 100644 --- a/src/sage/doctest/test.py +++ b/src/sage/doctest/test.py @@ -432,7 +432,7 @@ s...: a = 3 s...: b = 5 s...: a + b - 8 + 8... sage: Returning to doctests... diff --git a/src/sage/repl/ipython_extension.py b/src/sage/repl/ipython_extension.py index 792dbd14fd7..5b139c51e75 100644 --- a/src/sage/repl/ipython_extension.py +++ b/src/sage/repl/ipython_extension.py @@ -663,10 +663,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', ...) + ('incomplete', 4) sage: ip.input_transformer_manager.check_complete(''' ....: def foo(L) ....: K. = L''') diff --git a/src/sage/tests/cmdline.py b/src/sage/tests/cmdline.py index 27c614d290f..48b0b316820 100644 --- a/src/sage/tests/cmdline.py +++ b/src/sage/tests/cmdline.py @@ -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: Returning to doctests... From b4280d2f690b48b15d5a688105875b398d26ef0f Mon Sep 17 00:00:00 2001 From: Antonio Rojas Date: Sun, 2 Mar 2025 18:05:01 +0100 Subject: [PATCH 2/3] Disable IPython tips in doctest runner --- src/sage/doctest/forker.py | 1 + src/sage/doctest/test.py | 2 +- src/sage/tests/cmdline.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/sage/doctest/forker.py b/src/sage/doctest/forker.py index 85af26d20ad..97c49a287a7 100644 --- a/src/sage/doctest/forker.py +++ b/src/sage/doctest/forker.py @@ -1490,6 +1490,7 @@ def report_failure(self, out, test, example, got, globs): from sage.repl.configuration import sage_ipython_config from IPython.terminal.embed import InteractiveShellEmbed cfg = sage_ipython_config.default() + cfg.InteractiveShell.enable_tip = False # 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 diff --git a/src/sage/doctest/test.py b/src/sage/doctest/test.py index d8c579c6ef3..bbfa3acef01 100644 --- a/src/sage/doctest/test.py +++ b/src/sage/doctest/test.py @@ -432,7 +432,7 @@ s...: a = 3 s...: b = 5 s...: a + b - 8... + 8 sage: Returning to doctests... diff --git a/src/sage/tests/cmdline.py b/src/sage/tests/cmdline.py index 48b0b316820..27c614d290f 100644 --- a/src/sage/tests/cmdline.py +++ b/src/sage/tests/cmdline.py @@ -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: Returning to doctests... From 259ce4db3784164e471b42f9608ca97a4c436a27 Mon Sep 17 00:00:00 2001 From: Antonio Rojas Date: Tue, 4 Mar 2025 22:17:57 +0100 Subject: [PATCH 3/3] Move indirect doctest tag to a separate line --- src/sage/repl/ipython_extension.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sage/repl/ipython_extension.py b/src/sage/repl/ipython_extension.py index 5b139c51e75..661df8f3b3a 100644 --- a/src/sage/repl/ipython_extension.py +++ b/src/sage/repl/ipython_extension.py @@ -661,6 +661,7 @@ def init_line_transforms(self): Check that :issue:`31951` is fixed:: + sage: # indirect doctest sage: from IPython import get_ipython sage: ip = get_ipython() sage: ip.input_transformer_manager.check_complete('''