[Zope3-dev] Handling object memory addresses in doctests

Tim Peters tim.peters at gmail.com
Thu Feb 10 12:13:47 EST 2005


[Garrett Smith]
> As I haven't kept up on all of the latest enhancements to the doctest
> framework, is threre now a way to handle object memory addresses in
> doctests? E.g. this has been a problem:
>
>    Traceback (most recent call last):
>    NotFoundError: (<Foo object at 0x010E90D0>, 'foo')

doctest is part of Python, so the Python docs are the place to look. 
A pile of new "doctest directives" appeared in Python 2.4, documented
here:

    http://docs.python.org/lib/doctest-options.html

A good way to deal with your example is the ELLIPSIS directive; an
example on that page shows what's needed:

>>> print range(20) # doctest:+ELLIPSIS
[0, 1, ..., 18, 19]

Multiple ellipses can be used, and a linear-time
matching-with-wildcards algorithm is used under the covers.  See
testfsoids.py on the ZODB trunk for long examples using multiple
ellipses to hide variable details like specific transaction ids and
timestamps in multi-line expected output.


More information about the Zope3-dev mailing list