mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
Issue #7094: Add alternate ('#') flag to __format__ methods for float, complex and Decimal. Allows greater control over when decimal points appear. Added to make transitioning from %-formatting easier. '#g' still has a problem with Decimal which I'll fix soon.
This commit is contained in:
parent
c1d98d6850
commit
984bb58000
9 changed files with 87 additions and 36 deletions
|
|
@ -706,11 +706,8 @@ class RoundTestCase(unittest.TestCase):
|
|||
def test(fmt, value, expected):
|
||||
# Test with both % and format().
|
||||
self.assertEqual(fmt % value, expected, fmt)
|
||||
if not '#' in fmt:
|
||||
# Until issue 7094 is implemented, format() for floats doesn't
|
||||
# support '#' formatting
|
||||
fmt = fmt[1:] # strip off the %
|
||||
self.assertEqual(format(value, fmt), expected, fmt)
|
||||
fmt = fmt[1:] # strip off the %
|
||||
self.assertEqual(format(value, fmt), expected, fmt)
|
||||
|
||||
for fmt in ['%e', '%f', '%g', '%.0e', '%.6f', '%.20g',
|
||||
'%#e', '%#f', '%#g', '%#.20e', '%#.15f', '%#.3g']:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue