(self)
| 483 | eq(s.safe_substitute(self='bozo'), 'the self is bozo') |
| 484 | |
| 485 | def test_delimiter_override(self): |
| 486 | eq = self.assertEqual |
| 487 | raises = self.assertRaises |
| 488 | class AmpersandTemplate(Template): |
| 489 | delimiter = '&' |
| 490 | s = AmpersandTemplate('this &gift is for &{who} &&') |
| 491 | eq(s.substitute(gift='bud', who='you'), 'this bud is for you &') |
| 492 | raises(KeyError, s.substitute) |
| 493 | eq(s.safe_substitute(gift='bud', who='you'), 'this bud is for you &') |
| 494 | eq(s.safe_substitute(), 'this &gift is for &{who} &') |
| 495 | s = AmpersandTemplate('this &gift is for &{who} &') |
| 496 | raises(ValueError, s.substitute, dict(gift='bud', who='you')) |
| 497 | eq(s.safe_substitute(), 'this &gift is for &{who} &') |
| 498 | |
| 499 | class PieDelims(Template): |
| 500 | delimiter = '@' |
| 501 | s = PieDelims('@who likes to eat a bag of @{what} worth $100') |
| 502 | self.assertEqual(s.substitute(dict(who='tim', what='ham')), |
| 503 | 'tim likes to eat a bag of ham worth $100') |
| 504 | |
| 505 | def test_is_valid(self): |
| 506 | eq = self.assertEqual |
nothing calls this directly
no test coverage detected