From: Armin Ronacher Date: Thu, 12 Jun 2008 08:30:01 +0000 (+0200) Subject: Fixed a broken unittest and fixed a bug that required multiple tests to be put into... X-Git-Tag: 2.0~21 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e3290ea9f3c2579a819c9c4016beb50f20a41cad;p=jinja2.git Fixed a broken unittest and fixed a bug that required multiple tests to be put into parentheses for chaning. --HG-- branch : trunk --- diff --git a/jinja2/parser.py b/jinja2/parser.py index e73d820..810e381 100644 --- a/jinja2/parser.py +++ b/jinja2/parser.py @@ -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 = [] diff --git a/tests/test_syntax.py b/tests/test_syntax.py index a126b5f..986125c 100644 --- a/tests/test_syntax.py +++ b/tests/test_syntax.py @@ -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' diff --git a/tests/test_various.py b/tests/test_various.py index 535b97c..36f039a 100644 --- a/tests/test_various.py +++ b/tests/test_various.py @@ -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'