Re: Testing dictionary results with doctest

2008-10-31 Thread Paul Rubin
Joe Strout <[EMAIL PROTECTED]> writes: > >>> t.match( "The rain in Spain falls mainly on the train." ) > {'object': 'rain', 'location': 'Spain', 'subloc': 'train'} You can compare dictionaries for equality: >>> t.match( "The rain in Spain falls mainly on the train." ) == \ {'o

Re: Testing dictionary results with doctest

2008-10-31 Thread MRAB
On Oct 31, 2:43 pm, Joe Strout <[EMAIL PROTECTED]> wrote: > I love doctest -- the way it combines documentation with verification   > seems elegant and useful, and most of the time it's simple and easy to   > use. > > But I've run into a bit of a snag trying to test a method that returns   > a dict

Re: Testing dictionary results with doctest

2008-10-31 Thread bearophileHUGS
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'} True > Does doctest have some special wa

Re: Testing dictionary results with doctest

2008-10-31 Thread Duncan Booth
Joe Strout <[EMAIL PROTECTED]> wrote: > What's the standard solution for this? Should I iterate over the > sorted keys and print those out instead? Is there some built-in > method somewhere that will print a dictionary in a reliable order? > Does doctest have some special way to tell it t