I am writing my doctests like this:
>>> some_function(a=1, b=2)
{u'id': u'123', u'name': u'abc'}
This works fine for Python version 2.5, 2.6 & 2.7 but fails for Python 3 with following error:
Expected:
{u'id': u'123', u'name': u'abc'}
Got:
{'id': '123', 'name': 'abc'}
Problem is that if I write my doctests like this:
>>> some_function(a=1, b=2)
{'id': '123', 'name': 'abc'}
They will work only for Python3 and fail on Python2 version. My question is how do I make it cross version compatible?
u''to specify a literal, butrepr(somestring)will not use them, so the tests still will fail. Compare that to usingr''raw python literals; therwill be dropped from the representation as well. - Martijn Pieters♦>>> result = some_function(a=1, b=2) >>> print(result["id"])etc. - codeape