Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make String serialize empty string to empty string instead of null #73

Merged
merged 1 commit into from
Jan 10, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion colander/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 8 additions & 0 deletions colander/tests/test_colander.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down