Last active
December 19, 2015 18:29
-
-
Save mgedmin/5999095 to your computer and use it in GitHub Desktop.
A solution for dealing with str(some_float_value) differences in doctests, when you want your codebase to support both Python 2.6 and 2.7.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
from zope.testing.renormalizing import RENormalizing | |
FLOAT_CHECKER = RENormalizing([ | |
(re.compile(r'-?\d+[.]\d+'), | |
lambda m: '%.6g' % float(m.group(0))), | |
]) | |
... DocTestSuite(..., checker=FLOAT_CHECKER) ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment