summaryrefslogtreecommitdiff
path: root/Lib/test/test_float.py
diff options
context:
space:
mode:
authorEric Smith <eric@trueblade.com>2009-05-05 14:04:18 +0000
committerEric Smith <eric@trueblade.com>2009-05-05 14:04:18 +0000
commit37e55252f4ff2ec9c1f84b1c87a3ae226fefbf3a (patch)
tree6b997f06fc3f12228204a9782edfad3c679cff4c /Lib/test/test_float.py
parentedf4ca5448ce22ae6ce90ea4ed59e2dd90fce4c8 (diff)
downloadcpython-37e55252f4ff2ec9c1f84b1c87a3ae226fefbf3a.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_float.py')
-rw-r--r--Lib/test/test_float.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py
index fb6daafc0f..b617fa3702 100644
--- a/Lib/test/test_float.py
+++ b/Lib/test/test_float.py
@@ -284,6 +284,13 @@ class FormatTestCase(unittest.TestCase):
self.assertEqual(format(0.01, ''), '0.01')
self.assertEqual(format(0.01, 'g'), '0.01')
+ # empty presentation type should format in the same way as str
+ # (issue 5920)
+ x = 100/7.
+ self.assertEqual(format(x, ''), str(x))
+ self.assertEqual(format(x, '-'), str(x))
+ self.assertEqual(format(x, '>'), str(x))
+ self.assertEqual(format(x, '2'), str(x))
self.assertEqual(format(1.0, 'f'), '1.000000')