[py-dev] using docstrings for test descriptions

Frederik Dohr fdg001 at gmx.net
Tue Jul 7 11:30:17 CEST 2009


Hello all,

Holger's presentations at EuroPython last week convinced me that I 
should finally start migrating to py.test.

There's only one thing I'm missing: I'm used to providing fairly 
detailed descriptions for individual tests ("foo returns bar if baz").
While one could use the assert statement's second argument for this, 
that seems cumbersome and has some undesired side-effects (e.g. 
reporting "E    AssertionError: <description>" instead of displaying the 
respective values).
Docstrings appear to be the obvious (and pythonic) solution.

So I imagine a plugin could add docstring support, which might result in 
output as described here:
     http://gist.github.com/141977
(Being new to py.test, it is possible my expectations are misguided - 
don't hesitate to point out where that's the case.)

I'd be willing to look into how this might be implemented; it shouldn't 
be too hard (e.g. using a decorator), but some pointers on how to get 
started would be appreciated.


Thanks,

Fred



More information about the Pytest-dev mailing list