Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False means null #45

Merged
merged 2 commits into from Mar 28, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions colander/__init__.py
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
32 changes: 32 additions & 0 deletions colander/tests/test_colander.py
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down