Prevent template changing options (#20775)
* Prevent complex template validation changing input value * Remove deprecation warnings
This commit is contained in:
parent
e6cd04d711
commit
59393ab085
2 changed files with 18 additions and 8 deletions
|
@ -402,8 +402,7 @@ def test_template():
|
|||
schema = vol.Schema(cv.template)
|
||||
|
||||
for value in (None, '{{ partial_print }', '{% if True %}Hello', ['test']):
|
||||
with pytest.raises(vol.Invalid,
|
||||
message='{} not considered invalid'.format(value)):
|
||||
with pytest.raises(vol.Invalid):
|
||||
schema(value)
|
||||
|
||||
options = (
|
||||
|
@ -433,6 +432,15 @@ def test_template_complex():
|
|||
for value in options:
|
||||
schema(value)
|
||||
|
||||
# ensure the validator didn't mutate the input
|
||||
assert options == (
|
||||
1, 'Hello',
|
||||
'{{ beer }}',
|
||||
'{% if 1 == 1 %}Hello{% else %}World{% endif %}',
|
||||
{'test': 1, 'test2': '{{ beer }}'},
|
||||
['{{ beer }}', 1]
|
||||
)
|
||||
|
||||
|
||||
def test_time_zone():
|
||||
"""Test time zone validation."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue