From b7a1a71fcb2c7ae1c27e1339d557aab5ee28d88a Mon Sep 17 00:00:00 2001 From: pwwang Date: Wed, 16 Feb 2022 14:10:39 -0700 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Add=20tests=20regarding=20#47?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/wild/subtpl.liq | 1 + tests/wild/test_include.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 tests/wild/subtpl.liq create mode 100644 tests/wild/test_include.py diff --git a/tests/wild/subtpl.liq b/tests/wild/subtpl.liq new file mode 100644 index 0000000..89759ae --- /dev/null +++ b/tests/wild/subtpl.liq @@ -0,0 +1 @@ +|{{ variable }}| \ No newline at end of file diff --git a/tests/wild/test_include.py b/tests/wild/test_include.py new file mode 100644 index 0000000..af048fb --- /dev/null +++ b/tests/wild/test_include.py @@ -0,0 +1,29 @@ +from liquid import Liquid +from pathlib import Path + +def test_include(set_default_wild): + subtpl = Path(__file__).parent.joinpath("subtpl.liq") + + # default + tpl = f""" + {{% assign variable = 8525 %}} + {{% include "{subtpl}" %}} + """ + out = Liquid(tpl).render().strip() + assert out == "|8525|" + + # with context + tpl = f""" + {{% assign variable = 8525 %}} + {{% include "{subtpl}" with context %}} + """ + out = Liquid(tpl).render().strip() + assert out == "|8525|" + + # without context + tpl = f""" + {{% assign variable = 8525 %}} + {{% include "{subtpl}" without context %}} + """ + out = Liquid(tpl).render().strip() + assert out == "||"