From 73b35e2cbc4cb61aac7921fefb7b96715e50d228 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Tue, 6 Nov 2018 12:42:08 +0100 Subject: [PATCH] misc: fix ezt [is ...] usage with lazy field variables (#27781) --- tests/test_formdata.py | 8 ++++++++ wcs/qommon/ezt.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/test_formdata.py b/tests/test_formdata.py index f6bf8ff27..830e87dfd 100644 --- a/tests/test_formdata.py +++ b/tests/test_formdata.py @@ -722,6 +722,14 @@ def test_lazy_templates(pub, variable_test_data): tmpl = Template('{{form_user_name_identifier_0}}') assert tmpl.render(context) == pub.user_class.select()[0].name_identifiers[0] +def test_lazy_ezt_templates(pub, variable_test_data): + context = pub.substitutions.get_context_variables(mode='lazy') + tmpl = Template('[form_var_foo_foo]') + assert tmpl.render(context) == 'bar' + + tmpl = Template('[is form_var_foo_foo "bar"]HELLO[else]BYE[end]') + assert tmpl.render(context) == 'HELLO' + def test_form_digest_date(pub): formdef = FormDef() formdef.name = 'foobar' diff --git a/wcs/qommon/ezt.py b/wcs/qommon/ezt.py index 026a0fe18..973e0fcaa 100644 --- a/wcs/qommon/ezt.py +++ b/wcs/qommon/ezt.py @@ -536,7 +536,7 @@ class Template: ((left_ref, right_ref), t_section, f_section) = args try: value = _get_value(right_ref, ctx) - value = string.lower(_get_value(left_ref, ctx)) == string.lower(value) + value = string.lower(str(_get_value(left_ref, ctx))) == string.lower(str(value)) except UnknownReference: value = False self._do_if(value, t_section, f_section, fp, ctx) -- 2.19.1