(self)
| 695 | |
| 696 | @support.requires_resource('cpu') |
| 697 | def test_format_combinations(self): |
| 698 | flags = '-+ #0' |
| 699 | testcases = [ |
| 700 | *product(('', '1234', 'абвг'), 'sra'), |
| 701 | *product((1234, -1234), 'duioxX'), |
| 702 | *product((1234.5678901, -1234.5678901), 'duifegFEG'), |
| 703 | *product((float('inf'), -float('inf')), 'fegFEG'), |
| 704 | ] |
| 705 | width_precs = [ |
| 706 | *product(('', '1', '30'), ('', '.', '.0', '.2')), |
| 707 | ('', '.40'), |
| 708 | ('30', '.40'), |
| 709 | ] |
| 710 | for value, suffix in testcases: |
| 711 | for width, prec in width_precs: |
| 712 | for r in range(len(flags) + 1): |
| 713 | for spec in combinations(flags, r): |
| 714 | fmt = '%' + ''.join(spec) + width + prec + suffix |
| 715 | with self.subTest(fmt=fmt, value=value): |
| 716 | s1 = fmt % value |
| 717 | s2 = eval(f'{fmt!r} % (x,)', {'x': value}) |
| 718 | self.assertEqual(s2, s1, f'{fmt = }') |
| 719 | |
| 720 | def test_format_misc(self): |
| 721 | def format(fmt, *values): |
nothing calls this directly
no test coverage detected