summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pep292.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-03-24 20:28:43 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-03-24 20:28:43 (GMT)
commit8ffe917cee26b83fed4f227c4ed16d4eec15dcf9 (patch)
tree3a2bbef671dcda71bfa36cf5a02d4b68d09cb98a /Lib/test/test_pep292.py
parentbe1eb1424121682081fed8996e87e2dfd238e7ea (diff)
downloadcpython-8ffe917cee26b83fed4f227c4ed16d4eec15dcf9.zip
cpython-8ffe917cee26b83fed4f227c4ed16d4eec15dcf9.tar.gz
cpython-8ffe917cee26b83fed4f227c4ed16d4eec15dcf9.tar.bz2
Issue #23671: string.Template now allows to specify the "self" parameter as
keyword argument. string.Formatter now allows to specify the "self" and the "format_string" parameters as keyword arguments.
Diffstat (limited to 'Lib/test/test_pep292.py')
-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 6da8d2e..fd5256c 100644
--- a/Lib/test/test_pep292.py
+++ b/Lib/test/test_pep292.py
@@ -26,6 +26,7 @@ class TestTemplate(unittest.TestCase):
self.assertEqual(s.substitute(dict(who='tim', what='ham')),
'tim likes to eat a bag of ham worth $100')
self.assertRaises(KeyError, s.substitute, dict(who='tim'))
+ self.assertRaises(TypeError, Template.substitute)
def test_regular_templates_with_braces(self):
s = Template('$who likes ${what} for ${meal}')
@@ -198,6 +199,9 @@ class TestTemplate(unittest.TestCase):
eq(s.substitute(dict(mapping='one'), mapping='two'),
'the mapping is two')
+ s = Template('the self is $self')
+ eq(s.substitute(self='bozo'), 'the self is bozo')
+
def test_keyword_arguments_safe(self):
eq = self.assertEqual
raises = self.assertRaises
@@ -216,6 +220,9 @@ class TestTemplate(unittest.TestCase):
raises(TypeError, s.substitute, d, {})
raises(TypeError, s.safe_substitute, d, {})
+ s = Template('the self is $self')
+ eq(s.safe_substitute(self='bozo'), 'the self is bozo')
+
def test_delimiter_override(self):
eq = self.assertEqual
raises = self.assertRaises