doctest: address in output
Skip Montanaro
skip at pobox.com
Wed May 5 00:03:31 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.
Param> Because the former seems to be *much* easier to read than the
Param> latter.
Param> The return value of the function is designed to be ignored in
Param> normal use.
Then make it return None and use a different function on those presumably
rare occasions where you need it.
Param> Doing something with it, like assigning it to a variable or using
Param> isinstance() as you suggest, would make the documentation both
Param> unclear as well as harder to read than it should be.
My apologies. It was unclear to me that you intended this to be primarily
documentation. I thought since you were running doctest it was primarily a
test case.
Param> Making a doctest hard to read would go against the purpose of
Param> having doctests at all. I may as well use the unittest module
Param> then.
Maybe not if the "test" part of "doctest" is more important than the "doc"
part.
Skip
More information about the Python-list
mailing list