Merge branch 'plamut-master'

This commit is contained in:
Chris McDonough
2013-08-17 09:36:51 +02:00
4 changed files with 15 additions and 3 deletions

View File

@@ -27,6 +27,10 @@ Bug Fixes
when the default_timezone is set. These previously had the default
timezone.
- ``colander.String`` schema type now raises ``colander.Invalid`` when trying
to deserialize a non-string item.
See https://github.com/Pylons/colander/issues/100
Features
~~~~~~~~

View File

@@ -112,3 +112,4 @@ Contributors
- Doug Latornell, 2013/03/17
- Clayton Parker, 2013/08/15
- Brian Sutherland, 2013/08/16
- Peter Lamut, 2013/08/16

View File

@@ -1131,7 +1131,7 @@ class String(SchemaType):
else:
result = text_type(cstruct)
else:
result = text_type(cstruct)
raise Invalid(node)
except Exception as e:
raise Invalid(node,
_('${val} is not a string: ${err}',

View File

@@ -1350,11 +1350,11 @@ class TestString(unittest.TestCase):
self.assertEqual(result, uni)
def test_deserialize_nonunicode_from_None(self):
import colander
value = object()
node = DummySchemaNode(None)
typ = self._makeOne()
result = typ.deserialize(node, value)
self.assertEqual(result, text_type(value))
self.assertRaises(colander.Invalid, typ.deserialize, node, value)
def test_deserialize_from_utf8(self):
uni = text_(b'\xe3\x81\x82', encoding='utf-8')
@@ -1372,6 +1372,13 @@ class TestString(unittest.TestCase):
result = typ.deserialize(node, utf16)
self.assertEqual(result, uni)
def test_deserialize_from_nonstring_obj(self):
import colander
value = object()
node = DummySchemaNode(None)
typ = self._makeOne()
self.assertRaises(colander.Invalid, typ.deserialize, node, value)
def test_serialize_null(self):
from colander import null
node = DummySchemaNode(None)