diff options
author | Nick Coghlan <ncoghlan@gmail.com> | 2011-03-14 22:54:37 (GMT) |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2011-03-14 22:54:37 (GMT) |
commit | d25fd4d7102cfa98dadd6bfeb5753ce419c3fb3b (patch) | |
tree | 91e5ad090a239c79ea62e02c914d65c488231f63 /Lib/test/test_pep292.py | |
parent | 750beda5353e3433df3978b6e9e3d57b6253e066 (diff) | |
download | cpython-d25fd4d7102cfa98dadd6bfeb5753ce419c3fb3b.zip cpython-d25fd4d7102cfa98dadd6bfeb5753ce419c3fb3b.tar.gz cpython-d25fd4d7102cfa98dadd6bfeb5753ce419c3fb3b.tar.bz2 |
Close #11505: Improve string.py coverage
Diffstat (limited to 'Lib/test/test_pep292.py')
-rw-r--r-- | Lib/test/test_pep292.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_pep292.py b/Lib/test/test_pep292.py index a967649..a1e52e9 100644 --- a/Lib/test/test_pep292.py +++ b/Lib/test/test_pep292.py @@ -42,6 +42,19 @@ class TestTemplate(unittest.TestCase): s = Template('$who likes $$') eq(s.substitute(dict(who='tim', what='ham')), 'tim likes $') + def test_invalid(self): + class MyPattern(Template): + pattern = r""" + (?: + (?P<invalid>) | + (?P<escaped>%(delim)s) | + @(?P<named>%(id)s) | + @{(?P<braced>%(id)s)} + ) + """ + s = MyPattern('$') + self.assertRaises(ValueError, s.substitute, dict()) + def test_percents(self): eq = self.assertEqual s = Template('%(foo)s $foo ${foo}') |