Hi Daniel, On 2014-07-28, Daniel Krenn <kr...@aon.at> wrote: > Background: The output of a doctest is a dictionary; therefore there is > some uncertainty about the ordering of the entires. To have the > dict-output, but get tested as well, I want to do the following: > > sage: dict = {'a': 'b', 'x': 'y'} # random > {'a': 'b', 'x': 'y'} > sage: sorted(dict.iteritems()) # hide doctest > [('a', 'b'), ('x', 'y')]
I'd suggest to remove the random test and keep the non-random test in the doc. I see no reason for hiding it. Another possibility to deal with randomness of string representation: Explicitly assign the expected result to a variable in the doctest, and test for equality (here I assume that you have a function/method returning a dictionary. Hence, for testing method "bar" of instance "Foo", you could do sage: D = {'a': 'b', 'x': 'y'} sage: D == Foo.bar(pi) True But testing against sorted(dict.iteritems()) is perfectly fine in the docs (of course it needs to be the case that the sorting of the dictionary keys is non-random). Best regards, Simon -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.