From 7d254c267e1eb01e3314a60967214f2c5a9ae876 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 23 Oct 2024 17:05:29 -0700 Subject: [PATCH 1/5] src/sage/doctest/control.py: Add # needs --- src/sage/doctest/control.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sage/doctest/control.py b/src/sage/doctest/control.py index e6fcc29a61b..b19905ae30c 100644 --- a/src/sage/doctest/control.py +++ b/src/sage/doctest/control.py @@ -1,4 +1,5 @@ # sage_setup: distribution = sagemath-repl +# sage.doctest: needs sage.all """ Classes involved in doctesting From e4f994fdf5c6910f430bd5178737269698e86758 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 7 Aug 2023 22:44:12 -0700 Subject: [PATCH 2/5] src/sage/doctest: sage -fixdoctests --only-tags --- src/sage/doctest/fixtures.py | 2 +- src/sage/doctest/util.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sage/doctest/fixtures.py b/src/sage/doctest/fixtures.py index 033b0671c06..5861cc3abe6 100644 --- a/src/sage/doctest/fixtures.py +++ b/src/sage/doctest/fixtures.py @@ -81,7 +81,7 @@ def reproducible_repr(val): frozenset(['a', 'b', 'c', 'd']) sage: print(reproducible_repr([1, frozenset("cab"), set("bar"), 0])) [1, frozenset(['a', 'b', 'c']), set(['a', 'b', 'r']), 0] - sage: print(reproducible_repr({3.0: "three", "2": "two", 1: "one"})) # optional - sage.rings.real_mpfr + sage: print(reproducible_repr({3.0: "three", "2": "two", 1: "one"})) # needs sage.rings.real_mpfr {'2': 'two', 1: 'one', 3.00000000000000: 'three'} sage: print(reproducible_repr("foo\nbar")) # demonstrate default case 'foo\nbar' diff --git a/src/sage/doctest/util.py b/src/sage/doctest/util.py index e51d8fc36ff..a016a70a24c 100644 --- a/src/sage/doctest/util.py +++ b/src/sage/doctest/util.py @@ -147,10 +147,10 @@ def annotate(self, object): sage: # needs sage.schemes sage: from sage.doctest.util import Timer - sage: Timer().start().annotate(EllipticCurve) - sage: EllipticCurve.cputime # random + sage: Timer().start().annotate(EllipticCurve) # needs sage.schemes + sage: EllipticCurve.cputime # random # needs sage.schemes 2.817255 - sage: EllipticCurve.walltime # random + sage: EllipticCurve.walltime # random # needs sage.schemes 1332649288.410404 """ object.cputime = self.cputime From 51eaf20336a9ff002e89f3837e6214a40ed0d24d Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 23 Oct 2024 17:10:30 -0700 Subject: [PATCH 3/5] src/sage/doctest/forker.py: Add # needs --- src/sage/doctest/forker.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sage/doctest/forker.py b/src/sage/doctest/forker.py index dfe57f59b0b..4e8c6b8ec11 100644 --- a/src/sage/doctest/forker.py +++ b/src/sage/doctest/forker.py @@ -1411,6 +1411,7 @@ def report_failure(self, out, test, example, got, globs): If debugging is turned on this function starts an IPython prompt when a test returns an incorrect answer:: + sage: # needs sage.symbolic (actually sage.all) sage: sage0.quit() sage: _ = sage0.eval("import doctest, sys, os, multiprocessing, subprocess") sage: _ = sage0.eval("from sage.doctest.parsing import SageOutputChecker") @@ -1562,6 +1563,7 @@ def report_unexpected_exception(self, out, test, example, exc_info): EXAMPLES:: + sage: # needs sage.symbolic (actually sage.all) sage: from sage.interfaces.sage0 import sage0 sage: sage0.quit() sage: _ = sage0.eval("import doctest, sys, os, multiprocessing, subprocess") @@ -2102,6 +2104,7 @@ def dispatch(self): EXAMPLES:: + sage: # needs sage.modules sage: from sage.doctest.control import DocTestController, DocTestDefaults sage: from sage.doctest.forker import DocTestDispatcher sage: from sage.doctest.reporting import DocTestReporter From 550589146de8db860f3dda9a0f8321c204ddb78c Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 3 Sep 2023 12:52:57 -0700 Subject: [PATCH 4/5] Add # needs sage.rings.real_mpfr and similar --- src/sage/doctest/control.py | 4 ++-- src/sage/doctest/parsing.py | 6 ++++-- src/sage/structure/coerce.pyx | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/sage/doctest/control.py b/src/sage/doctest/control.py index b19905ae30c..28bd5aaca07 100644 --- a/src/sage/doctest/control.py +++ b/src/sage/doctest/control.py @@ -675,10 +675,10 @@ def load_environment(self): sage: from sage.doctest.control import DocTestDefaults, DocTestController sage: DC = DocTestController(DocTestDefaults(), []) - sage: 'BipartiteGraph' in DC.load_environment().__dict__ + sage: 'BipartiteGraph' in DC.load_environment().__dict__ # needs sage.graphs True sage: DC = DocTestController(DocTestDefaults(environment='sage.doctest.all'), []) - sage: 'BipartiteGraph' in DC.load_environment().__dict__ + sage: 'BipartiteGraph' in DC.load_environment().__dict__ # needs sage.graphs False sage: 'run_doctests' in DC.load_environment().__dict__ True diff --git a/src/sage/doctest/parsing.py b/src/sage/doctest/parsing.py index 9446320f808..8fc008da96e 100644 --- a/src/sage/doctest/parsing.py +++ b/src/sage/doctest/parsing.py @@ -560,7 +560,7 @@ def parse_tolerance(source, want): 0 sage: marked.rel_tol 0 - sage: marked.abs_tol + sage: marked.abs_tol # needs sage.rings.real_mpfr 0.010000000000000000000...? """ # regular expressions @@ -870,7 +870,7 @@ def parse(self, string, *args): '0.893515349287690\n' sage: type(ex.want) - sage: ex.want.tol + sage: ex.want.tol # needs sage.rings.real_interval_field 2.000000000000000000...?e-11 You can use continuation lines:: @@ -1208,6 +1208,8 @@ class SageOutputChecker(doctest.OutputChecker): '0.893515349287690\n' sage: type(ex.want) + + sage: # needs sage.rings.real_interval_field sage: ex.want.tol 2.000000000000000000...?e-11 sage: OC.check_output(ex.want, '0.893515349287690', optflag) diff --git a/src/sage/structure/coerce.pyx b/src/sage/structure/coerce.pyx index 79d5ecb74e0..9700b353551 100644 --- a/src/sage/structure/coerce.pyx +++ b/src/sage/structure/coerce.pyx @@ -533,6 +533,7 @@ cdef class CoercionModel: Check that :issue:`8426` is fixed (see also :issue:`18076`):: + sage: # needs sage.rings.real_mpfr sage: import numpy # needs numpy sage: if int(numpy.version.short_version[0]) > 1: # needs numpy ....: numpy.set_printoptions(legacy="1.25") # needs numpy From d7c16750a22bbc60fc743cc4bbcfeb9c479dc3e5 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 23 Oct 2024 17:29:50 -0700 Subject: [PATCH 5/5] ./sage --fixdoctests --distribution 'sagemath-categories' --update-known-test-failures --- pkgs/sagemath-categories/known-test-failures.json | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pkgs/sagemath-categories/known-test-failures.json b/pkgs/sagemath-categories/known-test-failures.json index e9b0223ece4..d85f0c822a8 100644 --- a/pkgs/sagemath-categories/known-test-failures.json +++ b/pkgs/sagemath-categories/known-test-failures.json @@ -773,8 +773,7 @@ "ntests": 19 }, "sage.doctest.control": { - "failed": true, - "ntests": 229 + "ntests": 3 }, "sage.doctest.external": { "ntests": 42 @@ -784,7 +783,7 @@ }, "sage.doctest.forker": { "failed": true, - "ntests": 0 + "ntests": 366 }, "sage.doctest.marked_output": { "failed": true, @@ -792,7 +791,7 @@ }, "sage.doctest.parsing": { "failed": true, - "ntests": 275 + "ntests": 270 }, "sage.doctest.reporting": { "ntests": 126 @@ -1537,7 +1536,7 @@ }, "sage.rings.fraction_field": { "failed": true, - "ntests": 197 + "ntests": 193 }, "sage.rings.fraction_field_element": { "failed": true,