doctest, comparison control

Tim Peters tim.one at home.com
Tue May 15 21:41:11 EDT 2001


[Bruce Edge]
> Is there any way to specify fields to ignore in the result from a test?

No:  doctest is WYSIWYG, and that's "a feature".

> One of my linked in C++ libs throws exception that include source
> file line number. THis throws off the test suite:
>
> *****************************************************************
> Failure in example: z.pxxl( XX , YY )
> from line #34 of test.zetest
> Expected:
> Error: User exception members: ('ze_i.cc', 1416 )
> Got:
> Error: User exception members: ('ze_i.cc', 1421 )

If

>>> z.pxxl( XX, YY)
Error: User exception members: ('ze_i.cc', 1416 )

is what's in your test, doctest wouldn't be doing its job if it let 1421 pass
without complaining.  Write a function to catch errors and reformat the
exception msg to suppress the stuff you don't care about; then call that
function explicitly in your examples; then WYSIWYG and also what you want to
test.





More information about the Python-list mailing list