I am transferring the python library from python 2 only in python 2 and 3 to one code base (2.6, 2.7 and 3.3+). The main problem is that many tests use something like this:
def test(self):
example = {u'foo': u'bar'}
self.assertEqual(str(example), "{u'foo': u'bar'}")
which works in python 2 but throws an exception in python3:
AssertionError: "{'foo': 'bar'}" != "{u'foo': u'bar'}"
Is there a standard way to solve these problems besides the “different test”? overload __repr__?
source
share