I\'m writing a doctest for a function that outputs a dictionary. The doctest looks like
>>> my_function()
{\'this\': \'is\', \'a\': \'dictionary\'}
I found it useful to use the deepdiff package in my doctests when testing arbitrarily nested data. For example:
def something_complicated():
"""
>>> from deepdiff import DeepDiff
>>> DeepDiff(something_complicated(),
... {'expected': {'output': ['a', 'b', 'c']}},
... ignore_order=True)
{}
"""
items = ['a', 'b', 'c']
random.shuffle(items)
return {'expected': {'output': items}}