Merge pull request #217 from tisdall/required_class
unify `required`, `null`, and `drop`
This commit is contained in:
@@ -22,7 +22,12 @@ from . import iso8601
|
|||||||
|
|
||||||
_ = translationstring.TranslationStringFactory('colander')
|
_ = translationstring.TranslationStringFactory('colander')
|
||||||
|
|
||||||
required = object()
|
class _required(object):
|
||||||
|
""" Represents a required value in colander-related operations. """
|
||||||
|
def __repr__(self):
|
||||||
|
return '<colander.required>'
|
||||||
|
|
||||||
|
required = _required()
|
||||||
_marker = required # bw compat
|
_marker = required # bw compat
|
||||||
|
|
||||||
class _null(object):
|
class _null(object):
|
||||||
@@ -46,7 +51,8 @@ class _drop(object):
|
|||||||
Represents a value that should be dropped if it is missing during
|
Represents a value that should be dropped if it is missing during
|
||||||
deserialization.
|
deserialization.
|
||||||
"""
|
"""
|
||||||
pass
|
def __repr__(self):
|
||||||
|
return '<colander.drop>'
|
||||||
|
|
||||||
drop = _drop()
|
drop = _drop()
|
||||||
|
|
||||||
|
@@ -3783,6 +3783,16 @@ class Test_null(unittest.TestCase):
|
|||||||
import pickle
|
import pickle
|
||||||
self.assertTrue(pickle.loads(pickle.dumps(null)) is null)
|
self.assertTrue(pickle.loads(pickle.dumps(null)) is null)
|
||||||
|
|
||||||
|
class Test_required(unittest.TestCase):
|
||||||
|
def test___repr__(self):
|
||||||
|
from colander import required
|
||||||
|
self.assertEqual(repr(required), '<colander.required>')
|
||||||
|
|
||||||
|
class Test_drop(unittest.TestCase):
|
||||||
|
def test___repr__(self):
|
||||||
|
from colander import drop
|
||||||
|
self.assertEqual(repr(drop), '<colander.drop>')
|
||||||
|
|
||||||
class Dummy(object):
|
class Dummy(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user