misc: add support for boolean values in ezt (#14279)
This commit is contained in:
parent
96aea1ff53
commit
44a1e2f0e6
|
@ -139,6 +139,17 @@ def test_datetime_qualifier(pub):
|
|||
assert output.getvalue() == '<p>02/01/2019 14:04</p>'
|
||||
|
||||
|
||||
def test_is_bool():
|
||||
template = Template()
|
||||
template.parse('<p>[is foo True]hello[end]</p>')
|
||||
output = io.StringIO()
|
||||
template.generate(output, {'foo': True})
|
||||
assert output.getvalue() == '<p>hello</p>'
|
||||
output = io.StringIO()
|
||||
template.generate(output, {'foo': False})
|
||||
assert output.getvalue() == '<p></p>'
|
||||
|
||||
|
||||
def test_unclosed_block():
|
||||
template = Template()
|
||||
with pytest.raises(UnclosedBlocksError):
|
||||
|
|
|
@ -657,6 +657,8 @@ def _get_value(value_ref, ctx):
|
|||
ob = ctx.defines[start]
|
||||
elif hasattr(ctx.data, start):
|
||||
ob = getattr(ctx.data, start)
|
||||
elif refname in ('True', 'False'):
|
||||
return bool(refname == 'True')
|
||||
else:
|
||||
raise UnknownReference(refname)
|
||||
|
||||
|
|
Loading…
Reference in New Issue