[Python-checkins] python/dist/src/Lib/test test_pep292.py,1.6,1.7
nnorwitz at users.sourceforge.net
nnorwitz at users.sourceforge.net
Sun Oct 17 18:27:20 CEST 2004
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv439/Lib/test
Modified Files:
test_pep292.py
Log Message:
Invalid patterns to substitute and safe_substitute would crash since pattern
is not a local variable. Add a test case.
Index: test_pep292.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pep292.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- test_pep292.py 14 Sep 2004 02:34:08 -0000 1.6
+++ test_pep292.py 17 Oct 2004 16:27:18 -0000 1.7
@@ -113,6 +113,18 @@
s = MyPattern('@bag.foo.who likes to eat a bag of @bag.what')
self.assertEqual(s.substitute(m), 'tim likes to eat a bag of ham')
+ class BadPattern(Template):
+ pattern = r"""
+ (?P<badname>.*) |
+ (?P<escaped>@{2}) |
+ @(?P<named>[_a-z][._a-z0-9]*) |
+ @{(?P<braced>[_a-z][._a-z0-9]*)} |
+ (?P<invalid>@) |
+ """
+ s = BadPattern('@bag.foo.who likes to eat a bag of @bag.what')
+ self.assertRaises(ValueError, s.substitute, {})
+ self.assertRaises(ValueError, s.safe_substitute, {})
+
def test_unicode_values(self):
s = Template('$who likes $what')
d = dict(who=u't\xffm', what=u'f\xfe\fed')
More information about the Python-checkins
mailing list