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

Method test_better_error_message_format

Lib/test/test_format.py:536–555  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

534
535 @unittest.expectedFailure # TODO: RUSTPYTHON
536 def test_better_error_message_format(self):
537 # https://bugs.python.org/issue20524
538 for value in [12j, 12, 12.0, "12"]:
539 with self.subTest(value=value):
540 # The format spec must be invalid for all types we're testing.
541 # '%M' will suffice.
542 bad_format_spec = '%M'
543 err = re.escape("Invalid format specifier "
544 f"'{bad_format_spec}' for object of type "
545 f"'{type(value).__name__}'")
546 with self.assertRaisesRegex(ValueError, err):
547 f"xx{{value:{bad_format_spec}}}yy".format(value=value)
548
549 # Also test the builtin format() function.
550 with self.assertRaisesRegex(ValueError, err):
551 format(value, bad_format_spec)
552
553 # Also test f-strings.
554 with self.assertRaisesRegex(ValueError, err):
555 eval("f'xx{value:{bad_format_spec}}yy'")
556
557 @unittest.expectedFailure # TODO: RUSTPYTHON
558 def test_unicode_in_error_message(self):

Callers

nothing calls this directly

Calls 6

subTestMethod · 0.80
escapeMethod · 0.80
assertRaisesRegexMethod · 0.80
formatFunction · 0.50
evalFunction · 0.50
formatMethod · 0.45

Tested by

no test coverage detected