Fixed a broken unittest and fixed a bug that required multiple tests to be put into...
authorArmin Ronacher <armin.ronacher@active-4.com>
Thu, 12 Jun 2008 08:30:01 +0000 (10:30 +0200)
committerArmin Ronacher <armin.ronacher@active-4.com>
Thu, 12 Jun 2008 08:30:01 +0000 (10:30 +0200)
--HG--
branch : trunk

jinja2/parser.py
tests/test_syntax.py
tests/test_various.py

index e73d820bf15b3aaf9965d7ec464e9654fc2a2943..810e381e13df1bd7950ea20b6a377c86eeb3e78a 100644 (file)
@@ -703,7 +703,11 @@ class Parser(object):
             args, kwargs, dyn_args, dyn_kwargs = self.parse_call(None)
         elif self.stream.current.type in ('name', 'string', 'integer',
                                           'float', 'lparen', 'lbracket',
-                                          'lbrace'):
+                                          'lbrace') and not \
+             self.stream.current.test_any('name:else', 'name:or',
+                                          'name:and'):
+            if self.stream.current.test('name:is'):
+                self.fail('You cannot chain multiple tests with is')
             args = [self.parse_expression()]
         else:
             args = []
index a126b5f18e0590de75359bfd5ebb7b5d6bfdb31c..986125c51d4105642035d67362a27c8ab109e6b8 100644 (file)
@@ -171,3 +171,8 @@ def test_contant_casing(env):
             str(const), str(const).lower(), str(const).upper()
         ))
         assert tmpl.render() == '%s|%s|' % (const, const)
+
+
+def test_test_chaining(env):
+    raises(TemplateSyntaxError, env.from_string, '{{ foo is string is sequence }}')
+    env.from_string('{{ 42 is string or 42 is number }}').render() == 'True'
index 535b97c80455cb03746d9219a95c22349d27024a..36f039a2c11a35bf1a83a40447e0eb4faa4f5a9d 100644 (file)
@@ -67,7 +67,7 @@ def test_item_and_attribute():
     for env in Environment(), SandboxedEnvironment():
         tmpl = env.from_string('{{ foo.items() }}')
         assert tmpl.render(foo={'items': 42}) == "[('items', 42)]"
-        tmpl = env.from_string('{{ foo|attr("items") }}')
+        tmpl = env.from_string('{{ foo|attr("items")() }}')
         assert tmpl.render(foo={'items': 42}) == "[('items', 42)]"
         tmpl = env.from_string('{{ foo["items"] }}')
         assert tmpl.render(foo={'items': 42}) == '42'