(self)
| 503 | 'tim likes to eat a bag of ham worth $100') |
| 504 | |
| 505 | def test_is_valid(self): |
| 506 | eq = self.assertEqual |
| 507 | s = Template('$who likes to eat a bag of ${what} worth $$100') |
| 508 | self.assertTrue(s.is_valid()) |
| 509 | |
| 510 | s = Template('$who likes to eat a bag of ${what} worth $100') |
| 511 | self.assertFalse(s.is_valid()) |
| 512 | |
| 513 | # if the pattern has an unrecognized capture group, |
| 514 | # it should raise ValueError like substitute and safe_substitute do |
| 515 | class BadPattern(Template): |
| 516 | pattern = r""" |
| 517 | (?P<badname>.*) | |
| 518 | (?P<escaped>@{2}) | |
| 519 | @(?P<named>[_a-z][._a-z0-9]*) | |
| 520 | @{(?P<braced>[_a-z][._a-z0-9]*)} | |
| 521 | (?P<invalid>@) | |
| 522 | """ |
| 523 | s = BadPattern('@bag.foo.who likes to eat a bag of @bag.what') |
| 524 | self.assertRaises(ValueError, s.is_valid) |
| 525 | |
| 526 | def test_get_identifiers(self): |
| 527 | eq = self.assertEqual |
nothing calls this directly
no test coverage detected