Projet

Général

Profil

0001-misc-fix-ezt-is-.-usage-with-lazy-field-variables-27.patch

Frédéric Péters, 06 novembre 2018 12:42

Télécharger (1,69 ko)

Voir les différences:

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(-)
tests/test_formdata.py
722 722
    tmpl = Template('{{form_user_name_identifier_0}}')
723 723
    assert tmpl.render(context) == pub.user_class.select()[0].name_identifiers[0]
724 724

  
725
def test_lazy_ezt_templates(pub, variable_test_data):
726
    context = pub.substitutions.get_context_variables(mode='lazy')
727
    tmpl = Template('[form_var_foo_foo]')
728
    assert tmpl.render(context) == 'bar'
729

  
730
    tmpl = Template('[is form_var_foo_foo "bar"]HELLO[else]BYE[end]')
731
    assert tmpl.render(context) == 'HELLO'
732

  
725 733
def test_form_digest_date(pub):
726 734
    formdef = FormDef()
727 735
    formdef.name = 'foobar'
wcs/qommon/ezt.py
536 536
    ((left_ref, right_ref), t_section, f_section) = args
537 537
    try:
538 538
      value = _get_value(right_ref, ctx)
539
      value = string.lower(_get_value(left_ref, ctx)) == string.lower(value)
539
      value = string.lower(str(_get_value(left_ref, ctx))) == string.lower(str(value))
540 540
    except UnknownReference:
541 541
      value = False
542 542
    self._do_if(value, t_section, f_section, fp, ctx)
543
-