#14290 closed defect (fixed)
Running doctests from within Sage doesn't work
Reported by: | roed | Owned by: | mvngu |
---|---|---|---|
Priority: | major | Milestone: | sage-5.9 |
Component: | doctest framework | Keywords: | |
Cc: | Merged in: | sage-5.9.beta2 | |
Authors: | David Roe | Reviewers: | Volker Braun |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | #12415, #14331, #13278 | Stopgaps: |
Description (last modified by )
Running doctests from within Sage results in any test that has output failing. For example:
sage: run_doctests(sage.algebras.algebra) Doctesting /Users/roed/sage/sage-5.9.beta0/devel/sage/sage/algebras/algebra.py Running doctests with ID 2013-03-17-01-02-17-09f21e8e. Doctesting 1 file. sage -t /Users/roed/sage/sage-5.9.beta0/devel/sage/sage/algebras/algebra.py ********************************************************************** File "/Users/roed/sage/sage-5.9.beta0/devel/sage/sage/algebras/algebra.py", line 29, in sage.algebras.algebra.is_Algebra Failed example: is_Algebra(R) Expected: True Got: True ********************************************************************** File "/Users/roed/sage/sage-5.9.beta0/devel/sage/sage/algebras/algebra.py", line 31, in sage.algebras.algebra.is_Algebra Failed example: sig_on_count() Expected: 0 Got: 0 ********************************************************************** 1 item had failures: 2 of 4 in sage.algebras.algebra.is_Algebra [3 tests, 2 failures, 0.1 s] ---------------------------------------------------------------------- sage -t /Users/roed/sage/sage-5.9.beta0/devel/sage/sage/algebras/algebra.py # 2 doctests failed ---------------------------------------------------------------------- Total time for all tests: 0.1 seconds cpu time: 0.1 seconds cumulative wall time: 0.1 seconds
This is the result of IPython coloring the output.
Apply
Attachments (2)
Change History (15)
Changed 7 years ago by
comment:1 Changed 7 years ago by
- Status changed from new to needs_review
comment:2 Changed 7 years ago by
- Dependencies set to #12415
comment:3 Changed 7 years ago by
- Reviewers set to Volker Braun
Positive review to your patch.
I still think that it would be nice to have a note added to the diff that there were ansi escape sequences, since they don't get printed and you are otherwise just left with two identical strings which makes it non-obvious why the doctest failed. So I rescued that piece of the patch from #14359.
comment:4 Changed 7 years ago by
- Description modified (diff)
- Status changed from needs_review to positive_review
Your patch looks good too.
comment:5 Changed 7 years ago by
- Dependencies changed from #12415 to #12415, #14331, #13278
- Status changed from positive_review to needs_work
comment:6 Changed 7 years ago by
comment:7 Changed 7 years ago by
- Status changed from needs_work to positive_review
Agreed, I must have done something wrong.
comment:8 Changed 7 years ago by
- Status changed from positive_review to needs_work
Concerning escapes: on OS X 10.8 I am seeing
\e[?1034h
(where \e
stands for the escape character).
Could you also check for this code (no idea what it does).
comment:9 Changed 7 years ago by
That is not a color code but smm = "turn meta on". Most likely coming from readline if you have the wrong TERM set.
I'll update the patch to generate better diagnostic for escape sequences.
comment:10 Changed 7 years ago by
- Status changed from needs_work to needs_review
The updated patch now makes all escape sequences visible (and doctestable):
EXAMPLES:: sage: print 'This ist \x1b[1mbold\x1b[0m text' This ist <CSI-1m>bold<CSI-0m> text
comment:11 Changed 7 years ago by
What does CSI
mean? I prefer to use ESC
always.
Also, are you sure want to mess with \x9b
? I think that won't go well with UTF-8.
comment:12 Changed 7 years ago by
- Description modified (diff)
- Merged in set to sage-5.9.beta2
- Resolution set to fixed
- Status changed from needs_review to closed
For the escape codes, see #14375.
comment:13 Changed 7 years ago by
- Component changed from doctest to doctest framework
I couldn't figure out a way to doctest this fix (since the problem only occurred when running doctests from IPython), but it's ready for review.