Testing dictionary results with doctest

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Fri Oct 31 16:28:46 CET 2008

Joe Strout:
> What's the standard solution for this?

I don't know of any standard solution, I generally sort the items in
some ways, or add the result, that has to be equal:
>>> r = foo()
>>> r == {'object': 'rain', 'location': 'Spain', 'subloc': 'train'}

> Does doctest have some special way to tell it to consider the result  
> as a dictionary rather than a string?  Or something else?

A more general solution like this for sets/dics may become useful...
do you have any idea regarding how to design it?


More information about the Python-list mailing list