Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Nested exclusion groups do not function as expected #302

Open
w-miller opened this issue Sep 1, 2017 · 0 comments
Open

Nested exclusion groups do not function as expected #302

w-miller opened this issue Sep 1, 2017 · 0 comments

Comments

@w-miller
Copy link

w-miller commented Sep 1, 2017

With the below schema, you would expect "foo" to be exclusive with both "bar" and "baz":

>>> s = Schema({Exclusive(Exclusive("foo", 1), 2): str, Exclusive("bar", 1): str, Exclusive("baz", 2): str})

However, it appears that the inner 'Exclusive' object is ignored when they are nested. So "foo" does exclude "baz", as expected:

>>> s({"foo": "", "baz":"",})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/wmiller/venv/lib/python2.7/site-packages/voluptuous/schema_builder.py", line 221, in __call__
    return self._compiled([], data)
  File "/home/wmiller/venv/lib/python2.7/site-packages/voluptuous/schema_builder.py", line 520, in validate_dict
    raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: two or more values in the same group of exclusion '2' @ data[<2>]

But "foo" does not exclude "bar":

>>> s({"foo": "", "bar":"",})
{'foo': '', 'bar': ''}

The tests above were performed on voluptuous 0.10.5.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant