| 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): |