diff options
author | Barry Warsaw <barry@python.org> | 2004-11-01 03:52:43 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2004-11-01 03:52:43 (GMT) |
commit | 8c72eae2378fde4e473feadd4c7139d9ec9cb8e3 (patch) | |
tree | 6d780db607a15f5d3c025cbfaa7f7fb6811da93d /Lib/test | |
parent | 4590c00e89e349d6ec7247d1c4e7e22222e8ae76 (diff) | |
download | cpython-8c72eae2378fde4e473feadd4c7139d9ec9cb8e3.zip cpython-8c72eae2378fde4e473feadd4c7139d9ec9cb8e3.tar.gz cpython-8c72eae2378fde4e473feadd4c7139d9ec9cb8e3.tar.bz2 |
SF patch #1056967, changes the semantics of Template.safe_substitute() to not
raise a ValueError for dangling delimiters (the delimiter itself is returned).
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_pep292.py | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/Lib/test/test_pep292.py b/Lib/test/test_pep292.py index 19952e4..2a4353a 100644 --- a/Lib/test/test_pep292.py +++ b/Lib/test/test_pep292.py @@ -163,20 +163,19 @@ class TestTemplate(unittest.TestCase): raises(TypeError, s.safe_substitute, d, {}) def test_delimiter_override(self): + eq = self.assertEqual + raises = self.assertRaises class AmpersandTemplate(Template): delimiter = '&' s = AmpersandTemplate('this &gift is for &{who} &&') - self.assertEqual(s.substitute(gift='bud', who='you'), - 'this bud is for you &') - self.assertRaises(KeyError, s.substitute) - self.assertEqual(s.safe_substitute(gift='bud', who='you'), - 'this bud is for you &') - self.assertEqual(s.safe_substitute(), - 'this &gift is for &{who} &') + eq(s.substitute(gift='bud', who='you'), 'this bud is for you &') + raises(KeyError, s.substitute) + eq(s.safe_substitute(gift='bud', who='you'), 'this bud is for you &') + eq(s.safe_substitute(), 'this &gift is for &{who} &') s = AmpersandTemplate('this &gift is for &{who} &') - self.assertRaises(ValueError, s.substitute, - dict(gift='bud', who='you')) - self.assertRaises(ValueError, s.safe_substitute) + raises(ValueError, s.substitute, dict(gift='bud', who='you')) + eq(s.safe_substitute(), 'this &gift is for &{who} &') + def test_main(): from test import test_support |