[TIP] doctests with either-or outcome
ziade.tarek at gmail.com
Sat Sep 27 06:22:15 PDT 2008
On Sat, Sep 27, 2008 at 2:37 PM, Michael Foord <fuzzyman at voidspace.org.uk>wrote:
> Pete Forman wrote:
> > "Rob Kirkpatrick" <robert.d.kirkpatrick at gmail.com> writes:
> > > Is there a way of having a doctest pass if it has EITHER output A
> > > or output B?
> > What about this approach?
> >>>> output = get_output()
> >>>> output in (output_A, output_B)
> > True
> In my opinion this is one of the problems with the doctest approach.
> Should this fail you get a 'False != True' message that doesn't show you
> what the actual output was.
But in the first place like Pete said, why the output differs ? why testing
the output of the command ?
This is not a good test to do.
I would rather test what should be the final state of the ressource, not the
output of the command
that builds it. A bit like a smoke test:
>>> i_dont_care = get_output()
Tarek Ziadé | Association AfPy | www.afpy.org
Blog FR | http://programmation-python.org
Blog EN | http://tarekziade.wordpress.com/
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the testing-in-python