From 55f51970a74b38656c6f902a93aad53d4afef4e7 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 7 May 2023 12:46:50 -0700 Subject: [PATCH] sage.doctest: Docstring/doctest cosmetics --- src/sage/doctest/forker.py | 19 +++++++++++++------ src/sage/doctest/parsing.py | 4 ++-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/sage/doctest/forker.py b/src/sage/doctest/forker.py index 9a39d3698bd..6a62fdccb83 100644 --- a/src/sage/doctest/forker.py +++ b/src/sage/doctest/forker.py @@ -1042,17 +1042,20 @@ def compile_and_execute(self, example, compiler, globs): sage: from sage.doctest.control import DocTestDefaults; DD = DocTestDefaults() sage: from sage.env import SAGE_SRC sage: import doctest, sys, os, hashlib - sage: DTR = SageDocTestRunner(SageOutputChecker(), verbose=False, sage_options=DD, optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS) + sage: DTR = SageDocTestRunner(SageOutputChecker(), verbose=False, sage_options=DD, + ....: optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS) sage: DTR.running_doctest_digest = hashlib.md5() - sage: filename = os.path.join(SAGE_SRC,'sage','doctest','forker.py') - sage: FDS = FileDocTestSource(filename,DD) + sage: filename = os.path.join(SAGE_SRC, 'sage', 'doctest', 'forker.py') + sage: FDS = FileDocTestSource(filename, DD) sage: globs = RecordingDict(globals()) sage: 'doctest_var' in globs False sage: doctests, extras = FDS.create_doctests(globs) sage: ex0 = doctests[0].examples[0] sage: flags = 32768 if sys.version_info.minor < 8 else 524288 - sage: compiler = lambda ex: compile(ex.source, '', 'single', flags, 1) + sage: def compiler(ex): + ....: return compile(ex.source, '', + ....: 'single', flags, 1) sage: DTR.compile_and_execute(ex0, compiler, globs) 1764 sage: globs['doctest_var'] @@ -1065,7 +1068,9 @@ def compile_and_execute(self, example, compiler, globs): Now we can execute some more doctests to see the dependencies. :: sage: ex1 = doctests[0].examples[1] - sage: compiler = lambda ex:compile(ex.source, '', 'single', flags, 1) + sage: def compiler(ex): + ....: return compile(ex.source, '', + ....: 'single', flags, 1) sage: DTR.compile_and_execute(ex1, compiler, globs) sage: sorted(list(globs.set)) ['R', 'a'] @@ -1077,7 +1082,9 @@ def compile_and_execute(self, example, compiler, globs): :: sage: ex2 = doctests[0].examples[2] - sage: compiler = lambda ex:compile(ex.source, '', 'single', flags, 1) + sage: def compiler(ex): + ....: return compile(ex.source, '', + ....: 'single', flags, 1) sage: DTR.compile_and_execute(ex2, compiler, globs) a + 42 sage: list(globs.set) diff --git a/src/sage/doctest/parsing.py b/src/sage/doctest/parsing.py index e585acf1e5d..579768d6a06 100644 --- a/src/sage/doctest/parsing.py +++ b/src/sage/doctest/parsing.py @@ -197,8 +197,8 @@ def parse_tolerance(source, want): OUTPUT: - - ``want`` if there are no tolerance tags specified; a - :class:`MarkedOutput` version otherwise. + ``want`` if there are no tolerance tags specified; a + :class:`MarkedOutput` version otherwise. EXAMPLES::