Skip to content

Commit

Permalink
Allow use of 'None' as 'missing' for DateTimes.
Browse files Browse the repository at this point in the history
  • Loading branch information
dnouri committed Dec 14, 2011
1 parent 3a1b50c commit 6a09583
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion colander/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,7 @@ def __init__(self, default_tzinfo=_marker):
self.default_tzinfo = default_tzinfo

def serialize(self, node, appstruct):
if appstruct is null:
if not appstruct:
return null

if type(appstruct) is datetime.date: # cant use isinstance; dt subs date
Expand Down
8 changes: 8 additions & 0 deletions colander/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,14 @@ def test_serialize_null(self):
result = typ.serialize(node, val)
self.assertEqual(result, colander.null)

def test_serialize_none(self):
import colander
val = None
node = DummySchemaNode(None)
typ = self._makeOne()
result = typ.serialize(node, val)
self.assertEqual(result, colander.null)

def test_serialize_with_garbage(self):
typ = self._makeOne()
node = DummySchemaNode(None)
Expand Down

0 comments on commit 6a09583

Please sign in to comment.