Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running doctests from within Sage doesn't work #14290

Closed
roed314 opened this issue Mar 17, 2013 · 20 comments
Closed

Running doctests from within Sage doesn't work #14290

roed314 opened this issue Mar 17, 2013 · 20 comments

Comments

@roed314
Copy link
Contributor

roed314 commented Mar 17, 2013

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

Depends on #12415
Depends on #14331
Depends on #13278

Component: doctest framework

Author: David Roe

Reviewer: Volker Braun

Merged: sage-5.9.beta2

Issue created by migration from https://trac.sagemath.org/ticket/14290

@roed314
Copy link
Contributor Author

roed314 commented Mar 17, 2013

Attachment: 14290.patch.gz

@roed314
Copy link
Contributor Author

roed314 commented Mar 17, 2013

comment:1

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.

@roed314
Copy link
Contributor Author

roed314 commented Mar 17, 2013

Author: David Roe

@roed314
Copy link
Contributor Author

roed314 commented Mar 17, 2013

Dependencies: #12415

@vbraun
Copy link
Member

vbraun commented Mar 26, 2013

Reviewer: Volker Braun

@vbraun
Copy link
Member

vbraun commented Mar 26, 2013

comment:3

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.

@roed314
Copy link
Contributor Author

roed314 commented Mar 26, 2013

comment:4

Your patch looks good too.

@roed314

This comment has been minimized.

@jdemeyer
Copy link

comment:5

This should be rebased to #14331 + #13278.

@jdemeyer
Copy link

Changed dependencies from #12415 to #12415, #14331, #13278

@vbraun
Copy link
Member

vbraun commented Mar 27, 2013

comment:6

Patch applies cleanly here on top of sage-5.9.beta1 + #14331 + #13278.

@jdemeyer
Copy link

comment:7

Agreed, I must have done something wrong.

@jdemeyer
Copy link

comment:8

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).

@vbraun
Copy link
Member

vbraun commented Mar 28, 2013

comment:9

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.

@vbraun
Copy link
Member

vbraun commented Mar 28, 2013

Updated patch

@vbraun
Copy link
Member

vbraun commented Mar 28, 2013

comment:10

Attachment: trac_14290_ansi_escapes_indication.patch.gz

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

@jdemeyer
Copy link

comment:11

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.

@jdemeyer
Copy link

Merged: sage-5.9.beta2

@jdemeyer

This comment has been minimized.

@jdemeyer
Copy link

comment:12

For the escape codes, see #14375.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants