Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fixed issue with 'required' not being set properly and added test #420

Merged
merged 1 commit into from
Apr 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions voluptuous/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
from voluptuous.util import u, Capitalize, Lower, Strip, Title, Upper


def test_new_required_test():
schema = Schema({
'my_key': All(int, Range(1, 20)),
}, required=True)
assert_true(schema.required)


def test_exact_sequence():
schema = Schema(ExactSequence([int, int]))
try:
Expand Down
2 changes: 2 additions & 0 deletions voluptuous/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,12 @@ def __init__(self, *validators, **kwargs):

def __voluptuous_compile__(self, schema):
self._compiled = []
old_required = schema.required
self.schema = schema
for v in self.validators:
schema.required = self.required
self._compiled.append(schema._compile(v))
schema.required = old_required
return self._run

def _run(self, path, value):
Expand Down