When I run doctests on different Python versions (2.5 vs 2.6) and different plattforms (FreeBSD vs Mac OS) strings get quoted differently:
Failed example:
decode('{"created_by":"test","guid":123,"num":5.00}')
Expected:
{'guid': 123, 'num': Decimal("5.00"), 'created_by': 'test'}
Got:
{'guid': 123, 'num': Decimal('5.00'), 'created_by': 'test'}
So on one box repr(decimal.Decimal(‘5.00’)) results in ‘Decimal(“5.00”)’ on the other in “Decimal(‘5.00’)”. Is there any way to get arround the issue withyout creating more compliated test logic?
This is actually because the
decimalmodule’s source code has changed: In python 2.4 and python2.5 thedecimal.Decimal.__repr__function contains:whereas in python2.6 it contains:
So in this case the best thing to do is just to print out
str()of the result and check the type separately if necessary…