]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
Switch to parameterizing api tests
authorKevin Brown <kevin@kevin-brown.com>
Sat, 16 May 2020 21:17:51 +0000 (17:17 -0400)
committerKevin Brown <kevin@kevin-brown.com>
Sat, 16 May 2020 21:17:51 +0000 (17:17 -0400)
tests/test_api.py

index 2679e8fb5dd1c71b741895fc3b23e384f251f265..759d5cc1583bf227a1e13b69e592c628abeffb6f 100644 (file)
@@ -194,22 +194,19 @@ class TestMeta:
         i = meta.find_referenced_templates(ast)
         assert list(i) == ["layout.html", "test.html", "meh.html", "muh.html"]
 
-    def test_find_included_templates(self, env):
-        ast = env.parse('{% include ["foo.html", "bar.html"] %}')
-        i = meta.find_referenced_templates(ast)
-        assert list(i) == ["foo.html", "bar.html"]
-
-        ast = env.parse('{% include ("foo.html", "bar.html") %}')
-        i = meta.find_referenced_templates(ast)
-        assert list(i) == ["foo.html", "bar.html"]
-
-        ast = env.parse('{% include ["foo.html", "bar.html", foo] %}')
-        i = meta.find_referenced_templates(ast)
-        assert list(i) == ["foo.html", "bar.html", None]
-
-        ast = env.parse('{% include ("foo.html", "bar.html", foo) %}')
+    @pytest.mark.parametrize(
+        "include,templates",
+        (
+            ('{% include ["foo.html", "bar.html"] %}', ["foo.html", "bar.html"]),
+            ('{% include ("foo.html", "bar.html") %}', ["foo.html", "bar.html"]),
+            ('{% include ["foo.html", "bar.html", foo] %}', ["foo.html", "bar.html", None]),
+            ('{% include ("foo.html", "bar.html", foo) %}', ["foo.html", "bar.html", None])
+        )
+    )
+    def test_find_included_templates(self, env, include, templates):
+        ast = env.parse(include)
         i = meta.find_referenced_templates(ast)
-        assert list(i) == ["foo.html", "bar.html", None]
+        assert list(i) == templates
 
 
 class TestStreaming: