Permalink
Browse files

Allow use of 'None' as 'missing' for DateTimes.

  • Loading branch information...
1 parent a958e60 commit 6c6849ceab8a4c7534af89959432972fe487bb29 @dnouri dnouri committed with chrneumann Dec 14, 2011
Showing with 9 additions and 1 deletion.
  1. +1 −1 colander/__init__.py
  2. +8 −0 colander/tests/test_colander.py
@@ -1231,7 +1231,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
@@ -1542,6 +1542,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)

0 comments on commit 6c6849c

Please sign in to comment.