On 12/06/2017 09:49 AM, Erik Bray wrote:
>
> Did anyone ever think up a better solution to this?
>
Whatever you do, you wind up with a big pile of dict output in the
middle of your test case. So (where possible) you might as well use that
space to define a new dict containing the expected value. For example,
>>> actual = some_computation()
>>> expected = { 1: "one",
... 2: "two",
... 9: "nine" }
>>> actual == expected
True
That's harder to do when the dict is buried in some other data
structure, but maybe we shouldn't be testing the exact string
representation of some big conglomerate in the first place -- do we
actually care what it is? Instead, we should test only what we care about.
Regardless, I don't think the framework should make it look like you can
rely on dicts being sorted when you can't. Users should be able to run
the EXAMPLES and see what we say they'll see.