[TIP] doctests with either-or outcome

Michael Foord fuzzyman at voidspace.org.uk
Sat Sep 27 05:37:42 PDT 2008


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.

Michael

-- 
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/
http://www.trypython.org/
http://www.ironpython.info/
http://www.theotherdelia.co.uk/
http://www.resolverhacks.net/




More information about the testing-in-python mailing list