MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_defaults_parameter

Method test_defaults_parameter

Lib/test/test_logging.py:4728–4746  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

4726 self.assertRaises(ValueError, logging.Formatter, '${asctime', style='$')
4727
4728 def test_defaults_parameter(self):
4729 fmts = ['%(custom)s %(message)s', '{custom} {message}', '$custom $message']
4730 styles = ['%', '{', '$']
4731 for fmt, style in zip(fmts, styles):
4732 f = logging.Formatter(fmt, style=style, defaults={'custom': 'Default'})
4733 r = self.get_record()
4734 self.assertEqual(f.format(r), 'Default Message with 2 placeholders')
4735 r = self.get_record("custom")
4736 self.assertEqual(f.format(r), '1234 Message with 2 placeholders')
4737
4738 # Without default
4739 f = logging.Formatter(fmt, style=style)
4740 r = self.get_record()
4741 self.assertRaises(ValueError, f.format, r)
4742
4743 # Non-existing default is ignored
4744 f = logging.Formatter(fmt, style=style, defaults={'Non-existing': 'Default'})
4745 r = self.get_record("custom")
4746 self.assertEqual(f.format(r), '1234 Message with 2 placeholders')
4747
4748 def test_invalid_style(self):
4749 self.assertRaises(ValueError, logging.Formatter, None, None, 'x')

Callers

nothing calls this directly

Calls 4

get_recordMethod · 0.95
formatMethod · 0.95
assertEqualMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected