[Python-Dev] Unittest/doctest formatting differences in 2.7a1?

Ian Bicking ianb at colorstudy.com
Wed Dec 9 18:45:58 CET 2009

On Wed, Dec 9, 2009 at 11:23 AM, Lennart Regebro <lregebro at jarn.com> wrote:

>  > Evolving the tests to avoid depending on these sorts of implementation
> > details is reasonable, IMO, and cuold even be considered a bugfix by
> > the Zope community.
> Evolving doctest.py so it can handle this by itself would be
> considered a bugfix by me. :)

It's about time doctest got another run of development anyway.  I can
imagine a couple features that might help:

* Already in there, but sometimes hard to enable, is ellipsis.  Can you
already do this?

    >>> throw_an_exception()
    Traceback (most recent call last):
    DesiredException: ...

I'd like to see doctests be able to enable the ELLIPSIS option internally
and globally (currently it can only be enabled outside the doctest, or for a
single line).

* Another option might be something version-specific, like:

    >>> throw_an_exception() # +python<2.7
    ... old exception ...
    >>> throw_an_exception() # +python>=2.7
    ... new exception ...

* Maybe slightly more general, would be the ability to extend OutputCheckers
more easily than currently.  Maybe for instance "# py_version(less=2.7)"
would enable the "py_version" output checker, which would always succeed if
the version was greater than or equal to 2.7 (effectively ignoring the
output).  Or, maybe checkers could be extended so they could actually
suppress the execution of code (avoiding throw_an_exception() from being
called twice).

* Or, something more explicit than ELLIPSIS but able also be more flexible
than currently possible, like:

    >>> throw_an_exception()
    Traceback (most recent call last):
    DesiredException: [[2.6 error message | 2.7 error message]]

Ian Bicking  |  http://blog.ianbicking.org  |
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20091209/dfc47c3e/attachment-0001.htm>

More information about the Python-Dev mailing list