]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
add tests and changelog 618/head
authorDavid Lord <davidism@gmail.com>
Fri, 7 Jul 2017 16:34:32 +0000 (09:34 -0700)
committerDavid Lord <davidism@gmail.com>
Fri, 7 Jul 2017 16:34:32 +0000 (09:34 -0700)
CHANGES
tests/test_imports.py

diff --git a/CHANGES b/CHANGES
index 6276b1157793e6e39ff11349d95274f184d01be8..500af4e4539a0078f945cc0a0f9dcaf6e7947cd7 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -28,10 +28,12 @@ Version 2.10
 - Add ``min`` and ``max`` filters. (`#475`_)
 - Add tests for all comparison operators: ``eq``, ``ne``, ``lt``, ``le``,
   ``gt``, ``ge``. (`#665`_)
+- ``import`` statement cannot end with a trailing comma. (`#618`_)
 
 .. _#469: https://github.com/pallets/jinja/pull/469
 .. _#475: https://github.com/pallets/jinja/pull/475
 .. _#478: https://github.com/pallets/jinja/pull/478
+.. _#618: https://github.com/pallets/jinja/pull/618
 .. _#665: https://github.com/pallets/jinja/pull/665
 
 Version 2.9.6
index a6d5161b14feb68f77259cfd30ee039294740112..4250eb9d048871aa08a2f69703137e527c9cbc8e 100644 (file)
@@ -11,7 +11,8 @@
 import pytest
 
 from jinja2 import Environment, DictLoader
-from jinja2.exceptions import TemplateNotFound, TemplatesNotFound
+from jinja2.exceptions import TemplateNotFound, TemplatesNotFound, \
+    TemplateSyntaxError
 
 
 @pytest.fixture
@@ -50,7 +51,24 @@ class TestImports(object):
         )
         assert t.render(foo=42) == '[42|23]'
 
-    def test_trailing_comma(self, test_env):
+    def test_import_needs_name(self, test_env):
+        test_env.from_string('{% from "foo" import bar %}')
+        test_env.from_string('{% from "foo" import bar, baz %}')
+
+        with pytest.raises(TemplateSyntaxError):
+            test_env.from_string('{% from "foo" import %}')
+
+    def test_no_trailing_comma(self, test_env):
+        with pytest.raises(TemplateSyntaxError):
+            test_env.from_string('{% from "foo" import bar, %}')
+
+        with pytest.raises(TemplateSyntaxError):
+            test_env.from_string('{% from "foo" import bar,, %}')
+
+        with pytest.raises(TemplateSyntaxError):
+            test_env.from_string('{% from "foo" import, %}')
+
+    def test_trailing_comma_with_context(self, test_env):
         test_env.from_string('{% from "foo" import bar, baz with context %}')
         test_env.from_string('{% from "foo" import bar, baz, with context %}')
         test_env.from_string('{% from "foo" import bar, with context %}')