doctest: address in output
Paramjit Oberoi
p_s_oberoi at hotmail.com
Tue May 4 16:41:10 EDT 2004
> > >>> mymodule.do_something()
> > <mymodule.coolObj object at ...>
>
> Why not just change your doctest to be
>
> >>> import mymodule
> >>> isinstance(mymodule.do_something(), mymodule.coolObj)
> True
>
> ? That avoids two problems, the issue of addresses and the possibility that
> the repr() of your coolObj class changes.
Because the former seems to be *much* easier to read than the latter.
The return value of the function is designed to be ignored in normal
use. Doing something with it, like assigning it to a variable or using
isinstance() as you suggest, would make the documentation both unclear
as well as harder to read than it should be.
Making a doctest hard to read would go against the purpose of having
doctests at all. I may as well use the unittest module then.
-param
More information about the Python-list
mailing list