[Checkins] SVN: zope.configuration/branches/tseaver-test_cleanup/src/zope/configuration/tests/test_fields.py Moar coverage for z.c.fields.Bool.
Tres Seaver
cvs-admin at zope.org
Wed May 9 20:24:19 UTC 2012
Log message for revision 125790:
Moar coverage for z.c.fields.Bool.
Changed:
U zope.configuration/branches/tseaver-test_cleanup/src/zope/configuration/tests/test_fields.py
-=-
Modified: zope.configuration/branches/tseaver-test_cleanup/src/zope/configuration/tests/test_fields.py
===================================================================
--- zope.configuration/branches/tseaver-test_cleanup/src/zope/configuration/tests/test_fields.py 2012-05-09 20:24:12 UTC (rev 125789)
+++ zope.configuration/branches/tseaver-test_cleanup/src/zope/configuration/tests/test_fields.py 2012-05-09 20:24:15 UTC (rev 125790)
@@ -205,7 +205,7 @@
self.assertEqual(context._pathed, 'relative/path')
-class BoolTests(unittest.TestCase):
+class BoolTests(unittest.TestCase, _ConformsToIFromUnicode):
def _getTargetClass(self):
from zope.configuration.fields import Bool
@@ -214,7 +214,26 @@
def _makeOne(self, *args, **kw):
return self._getTargetClass()(*args, **kw)
+ def test_fromUnicode_w_true_values(self):
+ values = ['1', 'true', 'yes', 't', 'y']
+ values += [x.upper() for x in values]
+ bo = self._makeOne()
+ for value in values:
+ self.assertEqual(bo.fromUnicode(value), True)
+ def test_fromUnicode_w_false_values(self):
+ values = ['0', 'false', 'no', 'f', 'n']
+ values += [x.upper() for x in values]
+ bo = self._makeOne()
+ for value in values:
+ self.assertEqual(bo.fromUnicode(value), False)
+
+ def test_fromUnicode_w_invalid(self):
+ from zope.schema import ValidationError
+ bo = self._makeOne()
+ self.assertRaises(ValidationError, bo.fromUnicode, 'notvalid')
+
+
class MessageIDTests(unittest.TestCase):
def _getTargetClass(self):
More information about the checkins
mailing list