Allow the use of 'missing=None' for Number

This commit is contained in:
Daniel Nouri
2012-08-15 13:18:38 +02:00
parent 979cd65705
commit 24f648dd14
4 changed files with 15 additions and 2 deletions

View File

@@ -1,6 +1,12 @@
Changes Changes
======= =======
Next release
------------
- Allow the use of 'missing=None' for Number. See
https://github.com/Pylons/colander/pull/59 .
0.9.8 (2012-04-27) 0.9.8 (2012-04-27)
------------------ ------------------

View File

@@ -951,7 +951,7 @@ class Number(SchemaType):
num = None num = None
def serialize(self, node, appstruct): def serialize(self, node, appstruct):
if not appstruct: if appstruct in (null, None):
return null return null
try: try:

View File

@@ -1192,6 +1192,13 @@ class TestInteger(unittest.TestCase):
result = typ.serialize(node, val) result = typ.serialize(node, val)
self.assertEqual(result, '1') self.assertEqual(result, '1')
def test_serialize_zero(self):
val = 0
node = DummySchemaNode(None)
typ = self._makeOne()
result = typ.serialize(node, val)
self.assertEqual(result, '0')
class TestFloat(unittest.TestCase): class TestFloat(unittest.TestCase):
def _makeOne(self): def _makeOne(self):
from colander import Float from colander import Float

View File

@@ -32,7 +32,7 @@ testing_extras = ['nose', 'coverage']
docs_extras = ['Sphinx'] docs_extras = ['Sphinx']
setup(name='colander', setup(name='colander',
version='0.9.8', version='0.9.9dev1',
description=('A simple schema-based serialization and deserialization ' description=('A simple schema-based serialization and deserialization '
'library'), 'library'),
long_description=README + '\n\n' + CHANGES, long_description=README + '\n\n' + CHANGES,