diff --git a/voluptuous/tests/tests.py b/voluptuous/tests/tests.py index 9d784bd..28598f7 100644 --- a/voluptuous/tests/tests.py +++ b/voluptuous/tests/tests.py @@ -67,24 +67,24 @@ def test_iterate_candidates(): def test_in(): """Verify that In works.""" - schema = Schema({"color": In(frozenset(["blue", "red", "yellow"]))}) + schema = Schema({"color": In(frozenset(["red", "blue", "yellow"]))}) schema({"color": "blue"}) try: schema({"color": "orange"}) except Invalid as e: - assert_equal(str(e), "value is not allowed for dictionary value @ data['color']") + assert_equal(str(e), "value must be one of ['blue', 'red', 'yellow'] for dictionary value @ data['color']") else: assert False, "Did not raise InInvalid" def test_not_in(): """Verify that NotIn works.""" - schema = Schema({"color": NotIn(frozenset(["blue", "red", "yellow"]))}) + schema = Schema({"color": NotIn(frozenset(["red", "blue", "yellow"]))}) schema({"color": "orange"}) try: schema({"color": "blue"}) except Invalid as e: - assert_equal(str(e), "value is not allowed for dictionary value @ data['color']") + assert_equal(str(e), "value must not be one of ['blue', 'red', 'yellow'] for dictionary value @ data['color']") else: assert False, "Did not raise NotInInvalid" diff --git a/voluptuous/validators.py b/voluptuous/validators.py index fd0aa90..5e9a932 100644 --- a/voluptuous/validators.py +++ b/voluptuous/validators.py @@ -738,7 +738,7 @@ def __call__(self, v): check = True if check: raise InInvalid(self.msg or - 'value must be one of {}'.format(self.container)) + 'value must be one of {}'.format(sorted(self.container))) return v def __repr__(self): @@ -759,7 +759,7 @@ def __call__(self, v): check = True if check: raise NotInInvalid(self.msg or - 'value must not be one of {}'.format(self.container)) + 'value must not be one of {}'.format(sorted(self.container))) return v def __repr__(self):