Skip to content

Commit

Permalink
Allow use of 'None' as 'missing' for Numbers.
Browse files Browse the repository at this point in the history
  • Loading branch information
philipp.thuerwaechter committed Jul 18, 2012
1 parent ccd865d commit 979cd65
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 @@ -951,7 +951,7 @@ class Number(SchemaType):
num = None

def serialize(self, node, appstruct):
if appstruct is null:
if not appstruct:
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 @@ -1148,6 +1148,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_emptystring(self):
import colander
val = ''
Expand Down

0 comments on commit 979cd65

Please sign in to comment.