Dealing with dicts in doctest
steve+comp.lang.python at pearwood.info
Thu Jul 5 21:40:12 EDT 2018
On Thu, 05 Jul 2018 19:56:59 +0100, MRAB wrote:
> What about sorting the items?
> def func(arg):
> """blah blah blah
> >>> sorted(func(1).items())
> [('a', 1), ('b', 2), ('c', 3)]
Hmmm.... it still has the disadvantage of putting the emphasis on the
sorted() function instead of the function being doctested, and obscuring
the fact that it returns a dict. But I actually like that.
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson
More information about the Python-list