Skip to content

Commit

Permalink
sage.doctest: Docstring/doctest cosmetics
Browse files Browse the repository at this point in the history
  • Loading branch information
mkoeppe committed May 7, 2023
1 parent b124f2a commit 55f5197
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
19 changes: 13 additions & 6 deletions src/sage/doctest/forker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, '<doctest sage.doctest.forker[0]>', 'single', flags, 1)
sage: def compiler(ex):
....: return compile(ex.source, '<doctest sage.doctest.forker[0]>',
....: 'single', flags, 1)
sage: DTR.compile_and_execute(ex0, compiler, globs)
1764
sage: globs['doctest_var']
Expand All @@ -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, '<doctest sage.doctest.forker[1]>', 'single', flags, 1)
sage: def compiler(ex):
....: return compile(ex.source, '<doctest sage.doctest.forker[1]>',
....: 'single', flags, 1)
sage: DTR.compile_and_execute(ex1, compiler, globs)
sage: sorted(list(globs.set))
['R', 'a']
Expand All @@ -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, '<doctest sage.doctest.forker[2]>', 'single', flags, 1)
sage: def compiler(ex):
....: return compile(ex.source, '<doctest sage.doctest.forker[2]>',
....: 'single', flags, 1)
sage: DTR.compile_and_execute(ex2, compiler, globs)
a + 42
sage: list(globs.set)
Expand Down
4 changes: 2 additions & 2 deletions src/sage/doctest/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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::
Expand Down

0 comments on commit 55f5197

Please sign in to comment.