Skip to content
Myr

test for new identifier lexer

Before adoption: this commit came in with the history the project adopted, so no landing records it.

currently fails on special case unicode

authored by David Lord · committed by David Lord · parent 2177fc4 · Browse files · 2 files+22 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+22 added−1 removed

  • tests:+21 added−0 removed
  • other:+1 added−1 removed

2 files+22 added−1 removed

modified:jinja2/lexer.py+1 added-1 removed
572 unmodified lines
573 value = str(value)574 if check_ident and not value.isidentifier():575 raise TemplateSyntaxError(576 'Invalid character in identifier',577 line, name, filename)577 lineno, name, filename)578 elif token == 'string':579 # try to unescape string580 try:581 value = self._normalize_newlines(value[1:-1]) \
154 unmodified lines
modified:tests/test_lexnparse.py+21 added
124 unmodified lines
125 expect = expected.get(keep, template)126 result = tmpl.render()127 assert result == expect, (keep, template, result, expect)128129 @pytest.mark.parametrize('name,valid', (130 ('foo', True),131 ('föö', True),132 ('き', True),133 ('_', True),134 ('1a', False),135 # special cases in addition to \w136 ('\u1885', True),137 ('\u1886', True),138 ('\u2118', True),139 ('\u212e', True),140 ))141 def test_name(self, env, name, valid):142 t = '{{ ' + name + ' }}'143144 if valid:145 # shouldn't raise146 env.from_string(t)147 else:148 pytest.raises(TemplateSyntaxError, env.from_string, t)149150151@pytest.mark.lexnparse152@pytest.mark.parser153class TestParser(object):154
480 unmodified lines