summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_string.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_string.py')
-rw-r--r--Lib/test/test_string.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_string.py b/Lib/test/test_string.py
index e786ab6..fdb3253 100644
--- a/Lib/test/test_string.py
+++ b/Lib/test/test_string.py
@@ -196,6 +196,18 @@ class ModuleTest(unittest.TestCase):
self.assertRaises(ValueError, format, '', '#')
self.assertRaises(ValueError, format, '', '#20')
+ def test_format_keyword_arguments(self):
+ fmt = string.Formatter()
+ self.assertEqual(fmt.format("-{arg}-", arg='test'), '-test-')
+ self.assertRaises(KeyError, fmt.format, "-{arg}-")
+ self.assertEqual(fmt.format("-{self}-", self='test'), '-test-')
+ self.assertRaises(KeyError, fmt.format, "-{self}-")
+ self.assertEqual(fmt.format("-{format_string}-", format_string='test'),
+ '-test-')
+ self.assertRaises(KeyError, fmt.format, "-{format_string}-")
+ self.assertEqual(fmt.format(arg='test', format_string="-{arg}-"),
+ '-test-')
+
class BytesAliasTest(unittest.TestCase):
def test_builtin(self):