Skip to content

Commit

Permalink
Failing test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
jg-rp committed Sep 10, 2024
1 parent e201fb4 commit 7245a1b
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 0 deletions.
2 changes: 2 additions & 0 deletions liquid/golden/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
from . import truncate_filter
from . import truncatewords_filter
from . import uniq_filter
from . import universal_end_tags
from . import unless_tag
from . import upcase_filter
from . import url_decode_filter
Expand Down Expand Up @@ -154,6 +155,7 @@
truncate_filter,
truncatewords_filter,
uniq_filter,
universal_end_tags,
unless_tag,
upcase_filter,
url_decode_filter,
Expand Down
118 changes: 118 additions & 0 deletions liquid/golden/universal_end_tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
"""Universal `end` tag test cases."""

from liquid.golden.case import Case

cases = [
Case(
description="end if",
template=r"{% if true %}foo{% end %}",
expect="foo",
future=True,
),
Case(
description="end if, else",
template=r"{% if false %}foo{% else %}bar{% end %}",
expect="bar",
future=True,
),
Case(
description="end if, elsif",
template=r"{% if false %}foo{% elsif true %}bar{% end %}",
expect="bar",
future=True,
),
Case(
description="end if, whitespace control",
template="{% if true -%}\nfoo\n{%- end %}",
expect="foo",
future=True,
),
Case(
description="end for",
template=r"{% for x in (1..2) %}{{ x }},{% end %}",
expect="1,2,",
future=True,
),
Case(
description="end for, else",
template=r"{% for x in a %}{{ x }},{% else %}bar{% end %}",
expect="bar",
future=True,
globals={"a": []},
),
Case(
description="end if, nested universal",
template="\n".join(
[
r"{% if true %}",
r"foo",
r"{% if true %}",
r"bar",
r"{% end %}",
r"{% end %}",
]
),
expect="\nfoo\n\nbar\n\n",
future=True,
),
Case(
description="end if, alternative, nested universal",
template="\n".join(
[
r"{% if false %}",
r"foo",
r"{% else %}",
r"{% if true %}",
r"bar",
r"{% end %}",
r"{% end %}",
]
),
expect="\n\nbar\n\n",
future=True,
),
Case(
description="end if, nested inner",
template="\n".join(
[
r"{% if true %}",
r"foo",
r"{% if true %}",
r"bar",
r"{% end %}",
r"{% endif %}",
]
),
expect="\nfoo\n\nbar\n\n",
future=True,
),
Case(
description="end if, nested outer",
template="\n".join(
[
r"{% if true %}",
r"foo",
r"{% if true %}",
r"bar",
r"{% endif %}",
r"{% end %}",
]
),
expect="\nfoo\n\nbar\n\n",
future=True,
),
Case(
description="liquid, end if",
template="\n".join(
[
r"{% liquid ",
r"if true",
r" echo 'foo'",
r"end",
r"%}",
]
),
expect="foo",
future=True,
),
]
7 changes: 7 additions & 0 deletions tests/test_render.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Liquid render tests."""

import asyncio
import unittest
from typing import List
Expand All @@ -14,6 +15,8 @@
from liquid.template import BoundTemplate
from liquid.template import FutureAwareBoundTemplate

# mypy: disable-error-code="no-untyped-def"


class RenderTestCase(unittest.TestCase):
def _test(
Expand Down Expand Up @@ -438,3 +441,7 @@ def test_special_properties(self):
def test_identifiers(self):
"""Test permitted identifiers."""
self._test(golden.identifiers.cases)

def test_universal_end_tags(self) -> None:
"""Test universal aka anonymous end tags."""
self._test(golden.universal_end_tags.cases)

0 comments on commit 7245a1b

Please sign in to comment.