From 5f6dc88e7e60cbec76254031e8be4fc126cabb95 Mon Sep 17 00:00:00 2001 From: Antonio Rojas Date: Sat, 28 Jun 2025 21:01:43 +0200 Subject: [PATCH 1/4] Use `python3 -m sage.doctest` in doctest results report if not using `sage-runtests` --- src/sage/doctest/control.py | 14 ++++---- src/sage/doctest/forker.py | 18 +++++----- src/sage/doctest/reporting.py | 22 ++++++------- src/sage/doctest/test.py | 62 +++++++++++++++++------------------ 4 files changed, 58 insertions(+), 58 deletions(-) diff --git a/src/sage/doctest/control.py b/src/sage/doctest/control.py index a5a6a1e1d0a..cbdc126beaa 100644 --- a/src/sage/doctest/control.py +++ b/src/sage/doctest/control.py @@ -1162,7 +1162,7 @@ def run_doctests(self): sage: DC.expand_files_into_sources() sage: DC.run_doctests() Doctesting 1 file. - sage -t .../sage/rings/homset.py + .../sage/rings/homset.py [... tests, ...s wall] ---------------------------------------------------------------------- All tests passed! @@ -1239,7 +1239,7 @@ def cleanup(self, final=True): sage: DC.run() Running doctests with ID ... Doctesting 1 file. - sage -t .../rings/all.py + .../rings/all.py [... tests, ...s wall] ---------------------------------------------------------------------- All tests passed! @@ -1443,7 +1443,7 @@ def run(self): sage: DC.run() Running doctests with ID ... Doctesting 1 file. - sage -t .../sage/sets/non_negative_integers.py + .../sage/sets/non_negative_integers.py [... tests, ...s wall] ---------------------------------------------------------------------- All tests passed! @@ -1467,7 +1467,7 @@ def run(self): Using --optional=external,sage Features to be detected: ... Doctesting 1 file. - sage -t ....py + ....py [0 tests, ...s wall] ---------------------------------------------------------------------- All tests passed! @@ -1493,7 +1493,7 @@ def run(self): Using --optional=sage... Features to be detected: ... Doctesting 1 file. - sage -t ....py + ....py [4 tests, ...s wall] ---------------------------------------------------------------------- All tests passed! @@ -1511,7 +1511,7 @@ def run(self): Using --optional=sage Features to be detected: ... Doctesting 1 file. - sage -t ....py + ....py [4 tests, ...s wall] ---------------------------------------------------------------------- All tests passed! @@ -1637,7 +1637,7 @@ def run_doctests(module, options=None): sage: run_doctests(sage.rings.all) Running doctests with ID ... Doctesting 1 file. - sage -t .../sage/rings/all.py + .../sage/rings/all.py [... tests, ...s wall] ---------------------------------------------------------------------- All tests passed! diff --git a/src/sage/doctest/forker.py b/src/sage/doctest/forker.py index d1f5c4ca85a..4f4ffc93510 100644 --- a/src/sage/doctest/forker.py +++ b/src/sage/doctest/forker.py @@ -1768,9 +1768,9 @@ def serial_dispatch(self): sage: DC.dispatcher = DD sage: DC.timer = Timer().start() sage: DD.serial_dispatch() - sage -t .../rings/homset.py + .../rings/homset.py [... tests, ...s wall] - sage -t .../rings/ideal.py + .../rings/ideal.py [... tests, ...s wall] """ for source in self.controller.sources: @@ -1814,9 +1814,9 @@ def parallel_dispatch(self): sage: DC.dispatcher = DD sage: DC.timer = Timer().start() sage: DD.parallel_dispatch() - sage -t .../databases/cremona.py + .../databases/cremona.py [... tests, ...s wall] - sage -t .../rings/big_oh.py + .../rings/big_oh.py [... tests, ...s wall] If the ``exitfirst=True`` option is given, the results for a failing @@ -1840,7 +1840,7 @@ def parallel_dispatch(self): ....: DC.dispatcher = DD ....: DC.timer = Timer().start() ....: DD.parallel_dispatch() - sage -t ... + ... ********************************************************************** File "...", line 2, in ... Failed example: @@ -2145,9 +2145,9 @@ def dispatch(self): sage: DC.dispatcher = DD sage: DC.timer = Timer().start() sage: DD.dispatch() - sage -t .../sage/modules/free_module_homspace.py + .../sage/modules/free_module_homspace.py [... tests, ...s wall] - sage -t .../sage/rings/big_oh.py + .../sage/rings/big_oh.py [... tests, ...s wall] """ if self.controller.options.serial: @@ -2209,7 +2209,7 @@ def __init__(self, source, options, funclist=[], baseline=None): sage: run_doctests(sage.rings.big_oh) # indirect doctest Running doctests with ID ... Doctesting 1 file. - sage -t .../sage/rings/big_oh.py + .../sage/rings/big_oh.py [... tests, ...s wall] ---------------------------------------------------------------------- All tests passed! @@ -2256,7 +2256,7 @@ def run(self): sage: run_doctests(sage.symbolic.units) # indirect doctest # needs sage.symbolic Running doctests with ID ... Doctesting 1 file. - sage -t .../sage/symbolic/units.py + .../sage/symbolic/units.py [... tests, ...s wall] ---------------------------------------------------------------------- All tests passed! diff --git a/src/sage/doctest/reporting.py b/src/sage/doctest/reporting.py index 54742cd6c1e..08b31fe085d 100644 --- a/src/sage/doctest/reporting.py +++ b/src/sage/doctest/reporting.py @@ -42,7 +42,7 @@ # **************************************************************************** import re -from sys import stdout +from sys import argv, stdout from signal import (SIGABRT, SIGALRM, SIGBUS, SIGFPE, SIGHUP, SIGILL, SIGINT, SIGKILL, SIGPIPE, SIGQUIT, SIGSEGV, SIGTERM) from sage.structure.sage_object import SageObject @@ -183,17 +183,17 @@ def report_head(self, source, fail_msg=None): sage: DC = DocTestController(DD, [filename]) sage: DTR = DocTestReporter(DC) sage: print(DTR.report_head(FDS)) - sage -t .../sage/doctest/reporting.py + .../sage/doctest/reporting.py The same with various options:: sage: DD.long = True sage: print(DTR.report_head(FDS)) - sage -t --long .../sage/doctest/reporting.py + ... --long .../sage/doctest/reporting.py sage: print(DTR.report_head(FDS, "Failed by self-sabotage")) - sage -t --long .../sage/doctest/reporting.py # Failed by self-sabotage + ... --long .../sage/doctest/reporting.py # Failed by self-sabotage """ - cmd = "sage -t" + cmd = "sage-runtests" if "sage-runtests" in argv[0] else "python3 -m sage.doctest" if self.controller.options.long: cmd += " --long" @@ -695,9 +695,9 @@ def finalize(self): sage: DC.sources = [None] * 4 # to fool the finalize method sage: DTR.finalize() ---------------------------------------------------------------------- - sage -t .../sage/doctest/reporting.py # Timed out - sage -t .../sage/doctest/reporting.py # Bad exit: 3 - sage -t .../sage/doctest/reporting.py # 1 doctest failed + .../sage/doctest/reporting.py # Timed out + .../sage/doctest/reporting.py # Bad exit: 3 + .../sage/doctest/reporting.py # 1 doctest failed ---------------------------------------------------------------------- Total time for all tests: 0.0 seconds cpu time: 0.0 seconds @@ -710,9 +710,9 @@ def finalize(self): sage: DTR.finalize() ---------------------------------------------------------------------- - sage -t .../sage/doctest/reporting.py # Timed out - sage -t .../sage/doctest/reporting.py # Bad exit: 3 - sage -t .../sage/doctest/reporting.py # 1 doctest failed + .../sage/doctest/reporting.py # Timed out + .../sage/doctest/reporting.py # Bad exit: 3 + .../sage/doctest/reporting.py # 1 doctest failed Doctests interrupted: 4/6 files tested ---------------------------------------------------------------------- Total time for all tests: 0.0 seconds diff --git a/src/sage/doctest/test.py b/src/sage/doctest/test.py index c6aa9ac6147..ebc4984324e 100644 --- a/src/sage/doctest/test.py +++ b/src/sage/doctest/test.py @@ -29,7 +29,7 @@ ....: "--random-seed=0", "--optional=sage", "longtime.rst"], **kwds) Running doctests... Doctesting 1 file. - sage -t --warn-long 0.0 --random-seed=0 longtime.rst + ... --warn-long 0.0 --random-seed=0 longtime.rst [0 tests, ...s wall] ---------------------------------------------------------------------- All tests passed! @@ -40,7 +40,7 @@ ....: "--random-seed=0", "--optional=sage", "-l", "longtime.rst"], **kwds) Running doctests... Doctesting 1 file. - sage -t --long --warn-long 0.0 --random-seed=0 longtime.rst + ... --long --warn-long 0.0 --random-seed=0 longtime.rst [1 test, ...s wall] ---------------------------------------------------------------------- All tests passed! @@ -54,7 +54,7 @@ ....: "--random-seed=0", "--optional=sage", "tolerance.rst"], **kwds) Running doctests... Doctesting 1 file. - sage -t --warn-long 0.0 --random-seed=0 tolerance.rst + ... --warn-long 0.0 --random-seed=0 tolerance.rst ********************************************************************** File "tolerance.rst", line ..., in sage.doctest.tests.tolerance Failed example: @@ -124,7 +124,7 @@ ....: "--random-seed=0", "--optional=sage", "-i", "initial.rst"], **kwds) Running doctests... Doctesting 1 file. - sage -t --warn-long 0.0 --random-seed=0 initial.rst + ... --warn-long 0.0 --random-seed=0 initial.rst ********************************************************************** File "initial.rst", line 4, in sage.doctest.tests.initial Failed example: @@ -144,7 +144,7 @@ ********************************************************************** ... ---------------------------------------------------------------------- - sage -t --warn-long 0.0 --random-seed=0 initial.rst # 5 doctests failed + ... --warn-long 0.0 --random-seed=0 initial.rst # 5 doctests failed ---------------------------------------------------------------------- ... 1 @@ -155,7 +155,7 @@ ....: "--random-seed=0", "--optional=sage", "--exitfirst", "initial.rst"], **kwds) Running doctests... Doctesting 1 file. - sage -t --warn-long 0.0 --random-seed=0 initial.rst + ... --warn-long 0.0 --random-seed=0 initial.rst ********************************************************************** File "initial.rst", line 4, in sage.doctest.tests.initial Failed example: @@ -167,7 +167,7 @@ ********************************************************************** ... ---------------------------------------------------------------------- - sage -t --warn-long 0.0 --random-seed=0 initial.rst # 1 doctest failed + ... --warn-long 0.0 --random-seed=0 initial.rst # 1 doctest failed ---------------------------------------------------------------------- ... 1 @@ -183,13 +183,13 @@ ....: "--random-seed=0", "--optional=sage", "99seconds.rst"], **kwds2) Running doctests... Doctesting 1 file. - sage -t --warn-long 0.0 --random-seed=0 99seconds.rst + ... --warn-long 0.0 --random-seed=0 99seconds.rst Timed out ********************************************************************** Tests run before process (pid=...) timed out: ... ---------------------------------------------------------------------- - sage -t --warn-long 0.0 --random-seed=0 99seconds.rst # Timed out + ... --warn-long 0.0 --random-seed=0 99seconds.rst # Timed out ---------------------------------------------------------------------- ... 4 @@ -200,7 +200,7 @@ ....: "--random-seed=0", "--optional=sage", "keyboardinterrupt.rst"], **kwds) Running doctests... Doctesting 1 file. - sage -t --warn-long 0.0 --random-seed=0 keyboardinterrupt.rst + ... --warn-long 0.0 --random-seed=0 keyboardinterrupt.rst ********************************************************************** File "keyboardinterrupt.rst", line 11, in sage.doctest.tests.keyboardinterrupt Failed example: @@ -212,7 +212,7 @@ ********************************************************************** ... ---------------------------------------------------------------------- - sage -t --warn-long 0.0 --random-seed=0 keyboardinterrupt.rst # 1 doctest failed + ... --warn-long 0.0 --random-seed=0 keyboardinterrupt.rst # 1 doctest failed ---------------------------------------------------------------------- ... 1 @@ -278,7 +278,7 @@ ....: "--random-seed=0", "--optional=sage", "abort.rst"], **kwds) Running doctests... Doctesting 1 file. - sage -t --warn-long 0.0 --random-seed=0 abort.rst + ... --warn-long 0.0 --random-seed=0 abort.rst Killed due to abort ********************************************************************** Tests run before process (pid=...) failed: @@ -291,7 +291,7 @@ ------------------------------------------------------------------------ ... ---------------------------------------------------------------------- - sage -t --warn-long 0.0 --random-seed=0 abort.rst # Killed due to abort + ... --warn-long 0.0 --random-seed=0 abort.rst # Killed due to abort ---------------------------------------------------------------------- ... 16 @@ -308,7 +308,7 @@ sage: print(proc.stdout.replace('sage:', 'sage').replace('....:', '')) Running doctests... Doctesting 1 file. - sage -t --warn-long 0.0 --random-seed=0 fail_and_die.rst + ... --warn-long 0.0 --random-seed=0 fail_and_die.rst ********************************************************************** File "fail_and_die.rst", line 8, in sage.doctest.tests.fail_and_die Failed example: @@ -328,7 +328,7 @@ sage os.kill(os.getpid(), signal.SIGKILL) ## line 9 ## ********************************************************************** ---------------------------------------------------------------------- - sage -t --warn-long 0.0 --random-seed=0 fail_and_die.rst # Killed due to kill signal + ... --warn-long 0.0 --random-seed=0 fail_and_die.rst # Killed due to kill signal ---------------------------------------------------------------------- ... sage: proc.returncode @@ -340,7 +340,7 @@ ....: "--random-seed=0", "--optional=sage", "sig_on.rst"], **kwds) Running doctests... Doctesting 1 file. - sage -t --warn-long 0.0 --random-seed=0 sig_on.rst + ... --warn-long 0.0 --random-seed=0 sig_on.rst ********************************************************************** File "sig_on.rst", line 6, in sage.doctest.tests.sig_on Failed example: @@ -354,7 +354,7 @@ 1 of 5 in sage.doctest.tests.sig_on [3 tests, 1 failure, ...] ---------------------------------------------------------------------- - sage -t --warn-long 0.0 --random-seed=0 sig_on.rst # 1 doctest failed + ... --warn-long 0.0 --random-seed=0 sig_on.rst # 1 doctest failed ---------------------------------------------------------------------- ... 1 @@ -369,7 +369,7 @@ sage: print(open(t).read()) # long time Running doctests... Doctesting 1 file. - sage -t --warn-long 0.0 --random-seed=0 simple_failure.rst + ... --warn-long 0.0 --random-seed=0 simple_failure.rst ********************************************************************** File "simple_failure.rst", line 7, in sage.doctest.tests.simple_failure Failed example: @@ -383,7 +383,7 @@ 1 of 5 in sage.doctest.tests.simple_failure [4 tests, 1 failure, ...] ---------------------------------------------------------------------- - sage -t --warn-long 0.0 --random-seed=0 simple_failure.rst # 1 doctest failed + ... --warn-long 0.0 --random-seed=0 simple_failure.rst # 1 doctest failed ---------------------------------------------------------------------- ... @@ -394,7 +394,7 @@ sage: print(open(t).read()) # long time Running doctests... Doctesting 1 file. - sage -t --warn-long 0.0 --random-seed=0 simple_failure.rst + ... --warn-long 0.0 --random-seed=0 simple_failure.rst ********************************************************************** File "simple_failure.rst", line 7, in sage.doctest.tests.simple_failure Failed example: @@ -408,7 +408,7 @@ 1 of 5 in sage.doctest.tests.simple_failure [4 tests, 1 failure, ...] ---------------------------------------------------------------------- - sage -t --warn-long 0.0 --random-seed=0 simple_failure.rst # 1 doctest failed + ... --warn-long 0.0 --random-seed=0 simple_failure.rst # 1 doctest failed ---------------------------------------------------------------------- ... @@ -419,7 +419,7 @@ ....: stdin=open(os.devnull), **kwds) Running doctests... Doctesting 1 file. - sage -t --warn-long 0.0 --random-seed=0 simple_failure.rst + ... --warn-long 0.0 --random-seed=0 simple_failure.rst ********************************************************************** File "simple_failure.rst", line 7, in sage.doctest.tests.simple_failure Failed example: @@ -442,7 +442,7 @@ 1 of 5 in sage.doctest.tests.simple_failure [4 tests, 1 failure, ...] ---------------------------------------------------------------------- - sage -t --warn-long 0.0 --random-seed=0 simple_failure.rst # 1 doctest failed + ... --warn-long 0.0 --random-seed=0 simple_failure.rst # 1 doctest failed ---------------------------------------------------------------------- ... 1 @@ -455,7 +455,7 @@ exec gdb ... Running doctests... Doctesting 1 file... - sage -t... 1second.rst... + ... 1second.rst... [2 tests, ...s wall] ---------------------------------------------------------------------- All tests passed! @@ -479,7 +479,7 @@ ....: "--random-seed=0", "--optional=sage", "--show-skipped", "show_skipped.rst"], **kwds) Running doctests ... Doctesting 1 file. - sage -t --warn-long 0.0 --random-seed=0 show_skipped.rst + ... --warn-long 0.0 --random-seed=0 show_skipped.rst 2 tests not run due to known bugs 1 gap test not run 1 long test not run @@ -498,7 +498,7 @@ ....: "--random-seed=0", "--show-skipped", "--optional=sage,gap", "show_skipped.rst"], **kwds) Running doctests ... Doctesting 1 file. - sage -t --long --warn-long 0.0 --random-seed=0 show_skipped.rst + ... --long --warn-long 0.0 --random-seed=0 show_skipped.rst 2 tests not run due to known bugs 1 not tested test not run 0 tests not run because we ran out of time @@ -513,7 +513,7 @@ ....: "--random-seed=0", "--show-skipped", "--optional=gAp", "show_skipped.rst"], **kwds) Running doctests ... Doctesting 1 file. - sage -t --long --warn-long 0.0 --random-seed=0 show_skipped.rst + ... --long --warn-long 0.0 --random-seed=0 show_skipped.rst 2 tests not run due to known bugs 1 not tested test not run 2 sage tests not run @@ -546,7 +546,7 @@ ....: "--random-seed=0", "--optional=sage", "atexit.rst"], **kwds2) Running doctests... Doctesting 1 file. - sage -t --warn-long 0.0 --random-seed=0 atexit.rst + ... --warn-long 0.0 --random-seed=0 atexit.rst [3 tests, ...s wall] ---------------------------------------------------------------------- All tests passed! @@ -566,7 +566,7 @@ ....: "--random-seed=0", "--optional=sage", "random_seed.rst"], **kwds) Running doctests... Doctesting 1 file. - sage -t --warn-long 0.0 --random-seed=0 random_seed.rst + ... --warn-long 0.0 --random-seed=0 random_seed.rst ********************************************************************** File "random_seed.rst", line 3, in sage.doctest.tests.random_seed Failed example: @@ -580,7 +580,7 @@ 1 of 2 in sage.doctest.tests.random_seed [1 test, 1 failure, ...s wall] ---------------------------------------------------------------------- - sage -t --warn-long 0.0 --random-seed=0 random_seed.rst # 1 doctest failed + ... --warn-long 0.0 --random-seed=0 random_seed.rst # 1 doctest failed ---------------------------------------------------------------------- ... 1 @@ -588,7 +588,7 @@ ....: "--random-seed=1", "--optional=sage", "random_seed.rst"], **kwds) Running doctests... Doctesting 1 file. - sage -t --warn-long 0.0 --random-seed=1 random_seed.rst + ... --warn-long 0.0 --random-seed=1 random_seed.rst [1 test, ...s wall] ---------------------------------------------------------------------- All tests passed! From ad76960ddc66c2bb8e6f2cb84971d8c25ff3c5ee Mon Sep 17 00:00:00 2001 From: Antonio Rojas Date: Sun, 29 Jun 2025 00:16:04 +0200 Subject: [PATCH 2/4] Fix test failure in cmdline.py --- src/sage/tests/cmdline.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/tests/cmdline.py b/src/sage/tests/cmdline.py index ef97674e951..7ef1099cd83 100644 --- a/src/sage/tests/cmdline.py +++ b/src/sage/tests/cmdline.py @@ -302,7 +302,7 @@ Debugging requires single-threaded operation, setting number of threads to 1. Running doctests with ID... Doctesting 1 file. - sage -t ... + ... ********************************************************************** File "...", line 3, in ... Failed example: From 4153df03cc746f0d35c6b1671d953988d4427234 Mon Sep 17 00:00:00 2001 From: Antonio Rojas Date: Mon, 25 Aug 2025 10:16:51 +0200 Subject: [PATCH 3/4] Fix merge --- src/sage/doctest/reporting.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/doctest/reporting.py b/src/sage/doctest/reporting.py index 193ac48277d..a05b47c85d8 100644 --- a/src/sage/doctest/reporting.py +++ b/src/sage/doctest/reporting.py @@ -44,7 +44,7 @@ import re import sys from signal import SIGABRT, SIGFPE, SIGILL, SIGINT, SIGSEGV, SIGTERM, Signals -from sys import stdout +from sys import argv, stdout from sage.doctest.external import available_software from sage.doctest.sources import DictAsObject From 7ff88f2fee37cbf15124a4b8d21f7ef23b24a734 Mon Sep 17 00:00:00 2001 From: Antonio Rojas Date: Mon, 25 Aug 2025 10:38:13 +0200 Subject: [PATCH 4/4] Fix two new tests expected output --- src/sage/doctest/test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/doctest/test.py b/src/sage/doctest/test.py index 06059f9493c..630730fadfc 100644 --- a/src/sage/doctest/test.py +++ b/src/sage/doctest/test.py @@ -54,7 +54,7 @@ ....: "--random-seed=0", "--optional=sage", "sleep2.rst"], **kwds) Running doctests... Doctesting 1 file. - sage -t --warn-long --random-seed=0 sleep2.rst + ... --warn-long --random-seed=0 sleep2.rst ********************************************************************** File "sleep2.rst", line 4, in sage.doctest.tests.sleep2 Warning: slow doctest: @@ -71,7 +71,7 @@ ....: "--random-seed=0", "--optional=sage", "sleep2.rst"], **kwds) Running doctests... Doctesting 1 file. - sage -t --warn-long --random-seed=0 sleep2.rst + ... --warn-long --random-seed=0 sleep2.rst ********************************************************************** ::warning title=Warning: slow doctest:,file=sleep2.rst,line=4::slow doctest:: Test ran for ...s cpu, ...s wall%0ACheck ran for ...s cpu, ...s wall%0A while walltime(t) < 2: pass