diff options
author | Eric Smith <eric@trueblade.com> | 2009-05-05 18:26:08 +0000 |
---|---|---|
committer | Eric Smith <eric@trueblade.com> | 2009-05-05 18:26:08 +0000 |
commit | a985a3aee46dfda4b59cf20414bab199ba1b9659 (patch) | |
tree | d7c3615c46cb9a17b3c330ab78c41dd6023adf2f /Lib/test/test_complex.py | |
parent | 929ab934891719ea1561a623ee1b2e502b59e022 (diff) | |
download | cpython-git-a985a3aee46dfda4b59cf20414bab199ba1b9659.tar.gz |
Issue #5920: Changed format.__float__ and complex.__float__ to use a precision of 12 when using the empty presentation type. This more closely matches str()'s behavior and reduces surprises when adding alignment flags to an empty format string. Patch by Mark Dickinson.
Diffstat (limited to 'Lib/test/test_complex.py')
-rw-r--r-- | Lib/test/test_complex.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_complex.py b/Lib/test/test_complex.py index 557e952bd1..56e9083eb7 100644 --- a/Lib/test/test_complex.py +++ b/Lib/test/test_complex.py @@ -467,6 +467,16 @@ class ComplexTest(unittest.TestCase): self.assertEqual(format(3+0j, ''), str(3+0j)) self.assertEqual(format(3.2+0j, ''), str(3.2+0j)) + # empty presentation type should still be analogous to str, + # even when format string is nonempty (issue #5920). + self.assertEqual(format(3.2+0j, '-'), str(3.2+0j)) + self.assertEqual(format(3.2+0j, '<'), str(3.2+0j)) + z = 4/7. - 100j/7. + self.assertEqual(format(z, ''), str(z)) + self.assertEqual(format(z, '-'), str(z)) + self.assertEqual(format(z, '<'), str(z)) + self.assertEqual(format(z, '10'), str(z)) + self.assertEqual(format(1+3j, 'g'), '1+3j') self.assertEqual(format(3j, 'g'), '0+3j') self.assertEqual(format(1.5+3.5j, 'g'), '1.5+3.5j') |