From 40a29fdedf981665163e485a1c6a62059795391e Mon Sep 17 00:00:00 2001 From: Tim Tisdall Date: Wed, 29 Apr 2015 16:56:30 +0000 Subject: [PATCH 1/2] unify `required`, `null`, and `drop` When I was trying to introspect schemas I printed out "missing: ", "missing: " and "missing: ". The first is supposed to be a colander.required but unfortunately it's just a generic object placeholder. This PR is to unify colander.required, colander.drop and colander.null. --- colander/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/colander/__init__.py b/colander/__init__.py index 1de747d..9355146 100644 --- a/colander/__init__.py +++ b/colander/__init__.py @@ -22,7 +22,12 @@ from . import iso8601 _ = translationstring.TranslationStringFactory('colander') -required = object() +class _required(object): + """ Represents a required value in colander-related operations. """ + def __repr__(self): + return '' + +required = _required() _marker = required # bw compat class _null(object): @@ -46,7 +51,8 @@ class _drop(object): Represents a value that should be dropped if it is missing during deserialization. """ - pass + def __repr__(self): + return '' drop = _drop() From 7e5e0e6b113d0c0f46965246378fbafecc572dd1 Mon Sep 17 00:00:00 2001 From: Tim Tisdall Date: Wed, 29 Apr 2015 18:29:09 +0000 Subject: [PATCH 2/2] fix coverage --- colander/tests/test_colander.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/colander/tests/test_colander.py b/colander/tests/test_colander.py index 8c342c8..6d05d71 100644 --- a/colander/tests/test_colander.py +++ b/colander/tests/test_colander.py @@ -3783,6 +3783,16 @@ class Test_null(unittest.TestCase): import pickle 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), '') + +class Test_drop(unittest.TestCase): + def test___repr__(self): + from colander import drop + self.assertEqual(repr(drop), '') + class Dummy(object): pass