From ccbb3c4dff2ff97327f90c7aaa5191ba42353a6c Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Wed, 30 Jan 2013 13:44:03 -0500 Subject: [PATCH] rename acceptable to choices --- colander/__init__.py | 12 +++++++----- colander/tests/test_colander.py | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/colander/__init__.py b/colander/__init__.py index f7bb024..e035c30 100644 --- a/colander/__init__.py +++ b/colander/__init__.py @@ -360,19 +360,21 @@ class OneOf(object): class ContainsOnly(object): """ Validator which succeeds if the value passed to is a sequence and each - element in the sequence is also in the sequence passed as ``acceptable`` + element in the sequence is also in the sequence passed as ``choices``. + This validator is useful when attached to a schemanode with, e.g. a + :class:`colander.Set` or another sequencetype. """ err_template = _( 'One or more of the choices you made was not acceptable' ) - def __init__(self, acceptable): - self.acceptable = set(acceptable) + def __init__(self, choices): + self.choices = choices def __call__(self, node, value): - if not set(value).issubset(self.acceptable): + if not set(value).issubset(self.choices): err = _( self.err_template, - mapping = {'val':value, 'acceptable':self.acceptable} + mapping = {'val':value, 'choices':self.choices} ) raise Invalid(node, err) diff --git a/colander/tests/test_colander.py b/colander/tests/test_colander.py index 6f962dc..127dce4 100644 --- a/colander/tests/test_colander.py +++ b/colander/tests/test_colander.py @@ -428,7 +428,7 @@ class TestContainsOnly(unittest.TestCase): def test_failure_with_custom_error_template(self): validator = self._makeOne([1]) from colander import _ - validator.err_template = _('${val}: ${acceptable}') + validator.err_template = _('${val}: ${choices}') e = invalid_exc(validator, None, [2]) self.assertTrue('[2]' in e.msg.interpolate())