Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'false_means_null' of https://github.com/chrneumann/cola…

  • Loading branch information...
commit 7e4fabd298e1aa6f0589f1476f40bca251debb1a 2 parents 60e93c3 + 3a75cb9
@dnouri dnouri authored
Showing with 36 additions and 4 deletions.
  1. +4 −4 colander/__init__.py
  2. +32 −0 colander/tests/test_colander.py
View
8 colander/__init__.py
@@ -901,7 +901,7 @@ def __init__(self, encoding=None):
self.encoding = encoding
def serialize(self, node, appstruct):
- if appstruct is null:
+ if not appstruct:
return null
try:
@@ -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
@@ -1307,7 +1307,7 @@ class Date(SchemaType):
err_template = _('Invalid date')
def serialize(self, node, appstruct):
- if appstruct is null:
+ if not appstruct:
return null
if isinstance(appstruct, datetime.datetime):
@@ -1383,7 +1383,7 @@ class Time(SchemaType):
err_template = _('Invalid time')
def serialize(self, node, appstruct):
- if appstruct is null:
+ if not appstruct:
return null
if isinstance(appstruct, datetime.datetime):
View
32 colander/tests/test_colander.py
@@ -1078,6 +1078,14 @@ def test_serialize_null(self):
result = typ.serialize(node, null)
self.assertEqual(result, 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_uncooperative(self):
val = Uncooperative()
node = DummySchemaNode(None)
@@ -1542,6 +1550,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)
@@ -1669,6 +1685,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)
@@ -1754,6 +1778,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)
Please sign in to comment.
Something went wrong with that request. Please try again.