@@ -759,23 +759,27 @@ Warnings
759759:mod: `doctest ` is serious about requiring exact matches in expected output. If
760760even a single character doesn't match, the test fails. This will probably
761761surprise you a few times, as you learn exactly what Python does and doesn't
762- guarantee about output. For example, when printing a dict, Python doesn't
763- guarantee that the key-value pairs will be printed in any particular order, so a
764- test like ::
762+ guarantee about output. For example, when printing a set, Python doesn't
763+ guarantee that the element is printed in any particular order, so a test like ::
765764
766765 >>> foo()
767- {"Hermione": "hippogryph" , "Harry": "broomstick "}
766+ {"Hermione", "Harry"}
768767
769768is vulnerable! One workaround is to do ::
770769
771- >>> foo() == {"Hermione": "hippogryph" , "Harry": "broomstick "}
770+ >>> foo() == {"Hermione", "Harry"}
772771 True
773772
774773instead. Another is to do ::
775774
776- >>> d = sorted(foo().items() )
775+ >>> d = sorted(foo())
777776 >>> d
778- [('Harry', 'broomstick'), ('Hermione', 'hippogryph')]
777+ ['Harry', 'Hermione']
778+
779+ .. note ::
780+
781+ Before Python 3.6, when printing a dict, Python did not guarantee that
782+ the key-value pairs was printed in any particular order.
779783
780784There are others, but you get the idea.
781785
0 commit comments