summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorThomas Wouters <thomas@python.org>2006-07-05 11:03:49 (GMT)
committerThomas Wouters <thomas@python.org>2006-07-05 11:03:49 (GMT)
commitadd191118fd583107e900c264f6e7aa1e786a387 (patch)
treeaff4b6d042a6b729021fcd11b7ed81b29ba81d2a /Lib/test
parent9ba7ca82298fabe84b633514317d795b42eef770 (diff)
downloadcpython-add191118fd583107e900c264f6e7aa1e786a387.zip
cpython-add191118fd583107e900c264f6e7aa1e786a387.tar.gz
cpython-add191118fd583107e900c264f6e7aa1e786a387.tar.bz2
Fix bug in passing tuples to string.Template. All other values (with working
str() or repr()) would work, just not multi-value tuples. Probably not a backport candidate, since it changes the behaviour of passing a single-element tuple: >>> string.Template("$foo").substitute(dict(foo=(1,))) '(1,)' versus '1'
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_pep292.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_pep292.py b/Lib/test/test_pep292.py
index 2a4353a..d1100ea 100644
--- a/Lib/test/test_pep292.py
+++ b/Lib/test/test_pep292.py
@@ -58,6 +58,13 @@ class TestTemplate(unittest.TestCase):
s = Template('tim has eaten ${count} bags of ham today')
eq(s.substitute(d), 'tim has eaten 7 bags of ham today')
+ def test_tupleargs(self):
+ eq = self.assertEqual
+ s = Template('$who ate ${meal}')
+ d = dict(who=('tim', 'fred'), meal=('ham', 'kung pao'))
+ eq(s.substitute(d), "('tim', 'fred') ate ('ham', 'kung pao')")
+ eq(s.safe_substitute(d), "('tim', 'fred') ate ('ham', 'kung pao')")
+
def test_SafeTemplate(self):
eq = self.assertEqual
s = Template('$who likes ${what} for ${meal}')