Permalink
Browse files

Make String serialize empty string to empty string instead of null

This makes the following True:
``` String().serialize(node, u'') == u'' ```

Issue #72
  • Loading branch information...
1 parent e2ef91c commit ad04ea68a7b7f4844b669f275e13828cc8a3add5 @tranminhh tranminhh committed Nov 16, 2012
Showing with 9 additions and 1 deletion.
  1. +1 −1 colander/__init__.py
  2. +8 −0 colander/tests/test_colander.py
View
@@ -982,7 +982,7 @@ def __init__(self, encoding=None):
self.encoding = encoding
def serialize(self, node, appstruct):
- if not appstruct:
+ if appstruct in (null, None):
return null
try:
@@ -1182,6 +1182,14 @@ def test_serialize_none(self):
result = typ.serialize(node, val)
self.assertEqual(result, colander.null)
+ def test_serialize_emptystring(self):
+ import colander
+ val = u''
+ node = DummySchemaNode(None)
+ typ = self._makeOne()
+ result = typ.serialize(node, val)
+ self.assertEqual(result, val)
+
def test_serialize_uncooperative(self):
val = Uncooperative()
node = DummySchemaNode(None)

0 comments on commit ad04ea6

Please sign in to comment.