content aslasals ls,als,as""",
jinja2.TemplateSyntaxError,
"Unclosed component",
),
# String attribute not closed
(
"""content""",
jinja2.TemplateSyntaxError,
"Syntax error",
),
# Expression not opem
(
"""content""",
jinja2.TemplateSyntaxError,
"Syntax error",
),
)
@pytest.mark.parametrize("source, exception, match", INVALID_DATA)
def test_process_invalid_tags(source, exception, match):
# Test the process_tags method of the JinjaX extension
env = jinja2.Environment()
jinjax = JinjaX(env)
with pytest.raises(exception, match=f".*{match}.*"):
jinjax.process_tags(source)
def test_process_nested_Same_tag():
# Test the process_tags method for the same tag nested
env = jinja2.Environment()
jinjax = JinjaX(env)
source = """
WTF
Text
"""
expected = """
{% call(_slot="") catalog.irender("Card", __prefix=__prefix, **{"class":"card"}) -%}
WTF
{% call(_slot="") catalog.irender("Card", __prefix=__prefix, **{"class":"card-header"}) -%}abc{%- endcall %}
{% call(_slot="") catalog.irender("Card", __prefix=__prefix, **{"class":"card-body"}) -%}
{% call(_slot="") catalog.irender("Card", __prefix=__prefix, **{}) -%}Text{%- endcall %}
{%- endcall %}
{%- endcall %}
"""
result = jinjax.process_tags(source)
print(result)
assert result.strip() == expected.strip()