(self)
| 685 | '{:._,f}'.format(1.1) |
| 686 | |
| 687 | def test_better_error_message_format(self): |
| 688 | # https://bugs.python.org/issue20524 |
| 689 | for value in [12j, 12, 12.0, "12"]: |
| 690 | with self.subTest(value=value): |
| 691 | # The format spec must be invalid for all types we're testing. |
| 692 | # '%M' will suffice. |
| 693 | bad_format_spec = '%M' |
| 694 | err = re.escape("Invalid format specifier " |
| 695 | f"'{bad_format_spec}' for object of type " |
| 696 | f"'{type(value).__name__}'") |
| 697 | with self.assertRaisesRegex(ValueError, err): |
| 698 | f"xx{{value:{bad_format_spec}}}yy".format(value=value) |
| 699 | |
| 700 | # Also test the builtin format() function. |
| 701 | with self.assertRaisesRegex(ValueError, err): |
| 702 | format(value, bad_format_spec) |
| 703 | |
| 704 | # Also test f-strings. |
| 705 | with self.assertRaisesRegex(ValueError, err): |
| 706 | eval("f'xx{value:{bad_format_spec}}yy'") |
| 707 | |
| 708 | def test_unicode_in_error_message(self): |
| 709 | str_err = re.escape( |
nothing calls this directly
no test coverage detected