From: philipp Date: Sun, 21 Apr 2013 20:07:11 +0000 (+0000) Subject: Changed DictValidator so that long and int datatypes are not treated as different... X-Git-Url: https://git.toastfreeware.priv.at/philipp/winterrodeln/wrpylib.git/commitdiff_plain/5b2dc6cc9b97290c265045ff01c849727e7df4df Changed DictValidator so that long and int datatypes are not treated as different anymore. git-svn-id: http://www.winterrodeln.org/svn/wrpylib/trunk@1375 7aebc617-e5e2-0310-91dc-80fb5f6d2477 --- diff --git a/tests/test_wrvalidators.py b/tests/test_wrvalidators.py index 19fca40..c28c576 100644 --- a/tests/test_wrvalidators.py +++ b/tests/test_wrvalidators.py @@ -142,6 +142,7 @@ def test_GermanPublicTransport(): assert v.from_python(4) == u'Schlecht' assert v.from_python(5) == u'Nein' assert v.from_python(6) == u'Ja' + assert v.from_python(1l) == u'Sehr gut' # test_GermanTristateFloatComment diff --git a/wrpylib/wrvalidators.py b/wrpylib/wrvalidators.py index 7d8b670..416e5d0 100644 --- a/wrpylib/wrvalidators.py +++ b/wrpylib/wrvalidators.py @@ -149,7 +149,8 @@ class DictValidator(formencode.FancyValidator): def from_python(self, value): for k, v in self.dict.iteritems(): - if type(v) == type(value) and v == value: return k + if v == value: + return k raise formencode.Invalid('Invalid value', value, None)