[py-dev] running doctest-based tests

Max Ischenko ischenko at gmail.com
Wed Jun 8 16:08:21 CEST 2005


> On Wed, Jun 08, 2005 at 14:18 +0300, Max Ischenko wrote:
> > I have made some progress in implementing it myself but stuck with some
> > mysterious error.
> >
> > I assume that the Item, when encounter a failure must raise a
corresponding
> > Outcome exception (which get caught by runtraced() method in session
module.
> >
> > In my case, it got caught but then py.test breaks nevertheless and shows
a
> > traceback that point to my raise Failed() statement. Somehow it
continues to
> > think of my code as part of client code, that as library code. This is
my
> > guess, at least.
> 
> I think the code is basically fine (i had a feeling of deja-vu, did you
> take this code from some py-dev posting? just curious ...).

That's it. ;) That's a sample code you wrote when replying to Ian.

> However, item.run() methods currently doesn't have direct means to control
> output in case of a test failure.  What we should do, i guess, is
> to say that an explicit 'py.test.skip()' doesn't print any traceback
> (maybe controlable by some command-line argument). Instead it prints
> only the given message.  You could then extend your doctest approach
> to produce the message you want py.test to show.

Sorry, don't get it. 

My problem is how to communicate test failures as reported by doctest back
to py.test.
If all tests pass then it works ok, printing correct test names and correct
number of dots (each doctest got a separate Item).

But when I'm trying to report failures to py.test  (using raise self.Failed)
I got this awkward traceback. I looked thru the py.test sources but the
exception is catched but then is magically re-thrown again. 

Either I'm doing something wrong (or in the wrong place) or there is a bug
in py.test (I'm using the HEAD trunk).





More information about the Pytest-dev mailing list