[Python-checkins] python/dist/src/Lib/test test_pep292.py,1.2,1.3
bwarsaw at users.sourceforge.net
bwarsaw at users.sourceforge.net
Mon Sep 13 16:36:02 CEST 2004
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31762
Modified Files:
test_pep292.py
Log Message:
Add tests for keyword arguments and combining mapping and keyword arguments.
Index: test_pep292.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pep292.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- test_pep292.py 10 Sep 2004 03:08:08 -0000 1.2
+++ test_pep292.py 13 Sep 2004 14:35:59 -0000 1.3
@@ -118,6 +118,34 @@
d = dict(who=u't\xffm', what=u'f\xfe\fed')
self.assertEqual(s.substitute(d), u't\xffm likes f\xfe\x0ced')
+ def test_keyword_arguments(self):
+ eq = self.assertEqual
+ s = Template('$who likes $what')
+ eq(s.substitute(who='tim', what='ham'), 'tim likes ham')
+ eq(s.substitute(dict(who='tim'), what='ham'), 'tim likes ham')
+ eq(s.substitute(dict(who='fred', what='kung pao'),
+ who='tim', what='ham'),
+ 'tim likes ham')
+ s = Template('the mapping is $mapping')
+ eq(s.substitute(dict(foo='none'), mapping='bozo'),
+ 'the mapping is bozo')
+ eq(s.substitute(dict(mapping='one'), mapping='two'),
+ 'the mapping is two')
+
+ def test_keyword_arguments_safe(self):
+ eq = self.assertEqual
+ s = Template('$who likes $what')
+ eq(s.safe_substitute(who='tim', what='ham'), 'tim likes ham')
+ eq(s.safe_substitute(dict(who='tim'), what='ham'), 'tim likes ham')
+ eq(s.safe_substitute(dict(who='fred', what='kung pao'),
+ who='tim', what='ham'),
+ 'tim likes ham')
+ s = Template('the mapping is $mapping')
+ eq(s.safe_substitute(dict(foo='none'), mapping='bozo'),
+ 'the mapping is bozo')
+ eq(s.safe_substitute(dict(mapping='one'), mapping='two'),
+ 'the mapping is two')
+
def suite():
suite = unittest.TestSuite()
More information about the Python-checkins
mailing list