doctest: address in output

Skip Montanaro skip at pobox.com
Tue May 4 13:09:26 EDT 2004


    Param> Recently (30 minutes ago...) I need to write a doctring of the
    Param> following type:

    >>>> import mymodule
    >>>> mymodule.do_something()
    Param> <mymodule.coolObj object at ...>

    Param> And I wanted to run doctest on this module. Now, I agree that
    Param> avoiding addresses in test output is a good thing in general;
    Param> but, in this case I wanted the '...' to match whatever address
    Param> the object happened to be at.

    [patch elided]

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.

Skip




More information about the Python-list mailing list