Skip to content

Commit

Permalink
Fixed issue with 'required' not being set properly and added test
Browse files Browse the repository at this point in the history
  • Loading branch information
EarQuack committed Mar 31, 2020
1 parent 82de2ef commit 415042e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
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

0 comments on commit 415042e

Please sign in to comment.