Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Closed
wants to merge 1 commit into from

2 participants

@dnouri
Collaborator

Related to #1

@dnouri
Collaborator

Fixed in #45.

@dnouri dnouri closed this
@pithu

would be nice to have the same behavior for Numbers: Allow use of 'None' as 'missing' for Number

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 14, 2011
  1. @dnouri
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 1 deletion.
  1. +1 −1  colander/__init__.py
  2. +8 −0 colander/tests.py
View
2  colander/__init__.py
@@ -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
View
8 colander/tests.py
@@ -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)
Something went wrong with that request. Please try again.