I ran into the same problem with doctests in IPython. There's no neat solution, but I wrapped all of the u'
prefixes in {}
, i.e. {u}'
, and made a little function that would include or exclude them as appropriate.
You can see the u_format() function and a doctest using it.
But that's rather messy, so I've moved many tests away from doctests.
Alternatively, you can test it like this:
>>> some_function(a=1, b=2) == {'id': '123', 'name': 'abc'}
True
If you need some unicode strings in the keys, you can use u'abþ'
, and use distribute to run 2to3
on the doctests. But that only works on input code, not output reprs.