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

Lennart Regebro lregebro at jarn.com
Wed Dec 9 18:56:03 CET 2009


On Wed, Dec 9, 2009 at 18:45, Ian Bicking <ianb at colorstudy.com> wrote:
> 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 think so, but what you need is:

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

Because one of the changes in Python 3 is that you now get the full
class path to the 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).

zope.testing has an output checker to which you can add transformers,
that's run on both the expected and actual output. Something like that
might work. We could then have a transformer that handles differences
in exception formats by default.

-- 
Lennart Regebro: Python, Zope, Plone, Grok
http://regebro.wordpress.com/
+33 661 58 14 64


More information about the Python-Dev mailing list