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

Method test_invalid_with_no_lines

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

Source from the content-addressed store, hash-verified

420 self.assertEqual(val, 'PyCon in Cleveland')
421
422 def test_invalid_with_no_lines(self):
423 # The error formatting for invalid templates
424 # has a special case for no data that the default
425 # pattern can't trigger (always has at least '$')
426 # So we craft a pattern that is always invalid
427 # with no leading data.
428 class MyTemplate(Template):
429 pattern = r"""
430 (?P<invalid>) |
431 unreachable(
432 (?P<named>) |
433 (?P<braced>) |
434 (?P<escaped>)
435 )
436 """
437 s = MyTemplate('')
438 with self.assertRaises(ValueError) as err:
439 s.substitute({})
440 self.assertIn('line 1, col 1', str(err.exception))
441
442 def test_unicode_values(self):
443 s = Template('$who likes $what')

Callers

nothing calls this directly

Calls 5

MyTemplateClass · 0.85
strFunction · 0.85
substituteMethod · 0.80
assertInMethod · 0.80
assertRaisesMethod · 0.45

Tested by

no test coverage detected