Opened 4 years ago
Closed 4 years ago
#26575 closed defect (fixed)
Doctest results starting with ...
Reported by: | roed | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-8.5 |
Component: | doctest framework | Keywords: | |
Cc: | caruso, jdemeyer | Merged in: | |
Authors: | David Roe | Reviewers: | Xavier Caruso |
Report Upstream: | N/A | Work issues: | |
Branch: | 4151b7e (Commits, GitHub, GitLab) | Commit: | 4151b7e5d3869daec54f376716ff6909b5c917ef |
Dependencies: | Stopgaps: |
Description
Currently, the Sage doctest framework gives ValueError in doctesting framework
if you try to start the doctest results with an ellipsis:
sage: from sage.doctest.parsing import SageDocTestParser sage: DTP = SageDocTestParser() sage: DTP.parse("sage: Zp(5,4,print_mode='digits')(5)\n...00010") Traceback (most recent call last): .../local/lib/python2.7/doctest.pyc in _check_prompt_blank(self, lines, indent, name, lineno) 787 for i, line in enumerate(lines): 788 if len(line) >= indent+4 and line[indent+3] != ' ': 789 raise ValueError('line %r of the docstring for %s ' 790 'lacks blank after %s: %r' % 791 (lineno+i+1, name, --> 792 line[indent:indent+3], line)) ... ValueError: line 2 of the docstring for <string> lacks blank after ...: '...00010'
The issue is that Python's doctester uses ellipses both for wildcard matching and for line continuations. So when the first line begins with an ellipsis, it can't distinguish between the two uses.
Most of the time in Sage, we use ....:
for line continuation, so we don't have this ambiguity. However, the doctesting framework still supports doctests written in plain Python.
I propose the following: if the doctest contains a line beginning with the Python doctest marker >>>
, we leave the behavior as is. Otherwise, allow ...
at the beginning of the results to behave as a wildcard matcher.
Change History (11)
comment:1 Changed 4 years ago by
- Branch set to u/roed/ellipses
comment:2 Changed 4 years ago by
- Commit set to 0fa318fe6dd4ac2520eea2abb71453b50cf37f8d
comment:3 Changed 4 years ago by
- Cc caruso jdemeyer added
There are some doctest failures
sage -t --long --warn-long 99.5 src/sage/interfaces/tachyon.py # 1 doctest failed sage -t --long --warn-long 99.5 src/sage/categories/category_with_axiom.py # 1 doctest failed sage -t --long --warn-long 99.5 src/sage/tests/books/judson-abstract-algebra/homomorph-sage.py # 1 doctest failed sage -t --long --warn-long 99.5 src/sage/interfaces/singular.py # 1 doctest failed sage -t --long --warn-long 99.5 src/sage/interfaces/gap.py # 1 doctest failed sage -t --long --warn-long 99.5 src/sage/rings/asymptotic/asymptotic_ring.py # 1 doctest failed sage -t --long --warn-long 99.5 src/sage/misc/cython.py # 2 doctests failed
which all seem to do with blank lines before tracebacks
File "src/sage/categories/category_with_axiom.py", line 1758, in sage.categories.category_with_axiom.base_category_class_and_axiom Failed example: base_category_class_and_axiom(Sets.Infinite) Expected: Traceback (most recent call last): ... TypeError: Could not retrieve the base category class and axiom for <class 'sage.categories.sets_cat.Sets.Infinite'>. ... Got: <BLANKLINE> Traceback (most recent call last): File "/home/roed/sage/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 659, in _run self.compile_and_execute(example, compiler, test.globs) File "/home/roed/sage/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 1070, in compile_and_execute exec(compiled, globs) File "<doctest sage.categories.category_with_axiom.base_category_class_and_axiom[11]>", line 1, in <module> base_category_class_and_axiom(Sets.Infinite) File "/home/roed/sage/local/lib/python2.7/site-packages/sage/categories/category_with_axiom.py", line 1796, in base_category_class_and_axiom See CategoryWithAxiom for details.""".format(cls)) TypeError: Could not retrieve the base category class and axiom for <class 'sage.categories.sets_cat.Sets.Infinite'>. Please specify it explicitly using the attribute _base_category_class_and_axiom. See CategoryWithAxiom for details. ********************************************************************** 1 item had failures: 1 of 13 in sage.categories.category_with_axiom.base_category_class_and_axiom [327 tests, 1 failure, 0.31 s]
I've seen these blank lines before, but I'm not sure what causes them....
comment:4 Changed 4 years ago by
- Branch changed from u/roed/ellipses to u/caruso/ellipses
- Commit changed from 0fa318fe6dd4ac2520eea2abb71453b50cf37f8d to f02ffa18b84080223bf1444e115a33c53cde640c
I just merged (and resolved conflicts) with sage 8.5.beta1
comment:5 Changed 4 years ago by
- Commit changed from f02ffa18b84080223bf1444e115a33c53cde640c to fc8df576dffa27fce860d6c941a3a50cbb2f7abc
Branch pushed to git repo; I updated commit sha1. New commits:
fc8df57 | Replace back <ELLIPSIS_TAG> by ... in exc_msg
|
comment:6 Changed 4 years ago by
- Status changed from new to needs_review
comment:7 Changed 4 years ago by
- Branch changed from u/caruso/ellipses to u/roed/ellipses
comment:8 Changed 4 years ago by
- Commit changed from fc8df576dffa27fce860d6c941a3a50cbb2f7abc to 4151b7e5d3869daec54f376716ff6909b5c917ef
comment:9 Changed 4 years ago by
- Status changed from needs_review to positive_review
Great. Then everything's alright, I give a positive review.
comment:10 Changed 4 years ago by
- Reviewers set to Xavier Caruso
comment:11 Changed 4 years ago by
- Branch changed from u/roed/ellipses to 4151b7e5d3869daec54f376716ff6909b5c917ef
- Resolution set to fixed
- Status changed from positive_review to closed
Branch pushed to git repo; I updated commit sha1. New commits:
No longer substitute for ... inside ....:, fix doctests