diff options
author | mike bayer <mike_mp@zzzcomputing.com> | 2022-08-29 17:59:10 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@ci3.zzzcomputing.com> | 2022-08-29 17:59:10 +0000 |
commit | b5ac84bafc80c3e56a1ede317b7ae4173e762a4a (patch) | |
tree | 6ed749d86ca00b55aa8c22e49db352bbc2f1de2c /test | |
parent | dbbaad3918c7d19cb71ca4b0b7ebe12661fba47b (diff) | |
parent | 925760291d6efec64fda6e9dd1fd9cfbd5be068c (diff) | |
download | mako-b5ac84bafc80c3e56a1ede317b7ae4173e762a4a.tar.gz |
Merge "fix tag regexp to match quoted groups correctly" into main
Diffstat (limited to 'test')
-rw-r--r-- | test/test_lexer.py | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/test/test_lexer.py b/test/test_lexer.py index 255c128..a7b6fe3 100644 --- a/test/test_lexer.py +++ b/test/test_lexer.py @@ -1,5 +1,7 @@ import re +import pytest + from mako import compat from mako import exceptions from mako import parsetree @@ -146,6 +148,10 @@ class LexerTest(TemplateTest): """ assert_raises(exceptions.CompileException, Lexer(template).parse) + def test_tag_many_quotes(self): + template = "<%0" + '"' * 3000 + assert_raises(exceptions.SyntaxException, Lexer(template).parse) + def test_unmatched_tag(self): template = """ <%namespace name="bar"> @@ -432,9 +438,16 @@ class LexerTest(TemplateTest): ), ) - def test_pagetag(self): - template = """ - <%page cached="True", args="a, b"/> + @pytest.mark.parametrize("comma,numchars", [(",", 48), ("", 47)]) + def test_pagetag(self, comma, numchars): + # note that the comma here looks like: + # <%page cached="True", args="a, b"/> + # that's what this test has looked like for decades, however, the + # comma there is not actually the right syntax. When issue #366 + # was fixed, the reg was altered to accommodate for this comma to allow + # backwards compat + template = f""" + <%page cached="True"{comma} args="a, b"/> some template """ @@ -453,7 +466,7 @@ class LexerTest(TemplateTest): some template """, - (2, 48), + (2, numchars), ), ], ), |