I\'m writing a doctest for a function that outputs a dictionary. The doctest looks like
>>> my_function() {\'this\': \'is\', \'a\': \'dictionary\'}
Most of it has been already said here.. anyway JSYK: there is a dedicated section in doctest documentation:
https://docs.python.org/3.5/library/doctest.html#warnings