MCPcopy Index your code
hub / github.com/python/cpython / test_braced_override_safe

Method test_braced_override_safe

Lib/test/test_string/test_string.py:405–420  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

403 self.assertEqual(val, 'PyCon in Cleveland')
404
405 def test_braced_override_safe(self):
406 class MyTemplate(Template):
407 pattern = r"""
408 \$(?:
409 (?P<escaped>$) |
410 (?P<named>[_a-z][_a-z0-9]*) |
411 @@(?P<braced>[_a-z][_a-z0-9]*)@@ |
412 (?P<invalid>) |
413 )
414 """
415
416 tmpl = 'PyCon in $@@location@@'
417 t = MyTemplate(tmpl)
418 self.assertEqual(t.safe_substitute(), tmpl)
419 val = t.safe_substitute({'location': 'Cleveland'})
420 self.assertEqual(val, 'PyCon in Cleveland')
421
422 def test_invalid_with_no_lines(self):
423 # The error formatting for invalid templates

Callers

nothing calls this directly

Calls 3

MyTemplateClass · 0.85
safe_substituteMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected