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

Method test_keyword_arguments

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

Source from the content-addressed store, hash-verified

445 self.assertEqual(s.substitute(d), 't\xffm likes f\xfe\x0ced')
446
447 def test_keyword_arguments(self):
448 eq = self.assertEqual
449 s = Template('$who likes $what')
450 eq(s.substitute(who='tim', what='ham'), 'tim likes ham')
451 eq(s.substitute(dict(who='tim'), what='ham'), 'tim likes ham')
452 eq(s.substitute(dict(who='fred', what='kung pao'),
453 who='tim', what='ham'),
454 'tim likes ham')
455 s = Template('the mapping is $mapping')
456 eq(s.substitute(dict(foo='none'), mapping='bozo'),
457 'the mapping is bozo')
458 eq(s.substitute(dict(mapping='one'), mapping='two'),
459 'the mapping is two')
460
461 s = Template('the self is $self')
462 eq(s.substitute(self='bozo'), 'the self is bozo')
463
464 def test_keyword_arguments_safe(self):
465 eq = self.assertEqual

Callers

nothing calls this directly

Calls 3

substituteMethod · 0.95
TemplateClass · 0.90
eqFunction · 0.85

Tested by

no test coverage detected