diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2009-04-29 18:47:07 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2009-04-29 18:47:07 (GMT) |
commit | d3ca55715028ac22981dadd3e4d9e61180f6e8bf (patch) | |
tree | 5ea324014421cb0a7626a7411aaf492ff2bb4a1e /Lib | |
parent | b507d2e07d19692df25a07c82f6d96ff1e4b4313 (diff) | |
download | cpython-d3ca55715028ac22981dadd3e4d9e61180f6e8bf.zip cpython-d3ca55715028ac22981dadd3e4d9e61180f6e8bf.tar.gz cpython-d3ca55715028ac22981dadd3e4d9e61180f6e8bf.tar.bz2 |
Issue #5864: Fix problem with empty code formatting for floats,
where a bogus trailing zero could be added.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/formatfloat_testcases.txt | 2 | ||||
-rw-r--r-- | Lib/test/test_float.py | 5 |
2 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/formatfloat_testcases.txt b/Lib/test/formatfloat_testcases.txt index 3abe938..287019f 100644 --- a/Lib/test/formatfloat_testcases.txt +++ b/Lib/test/formatfloat_testcases.txt @@ -339,6 +339,8 @@ %s 1e10 -> 10000000000.0 %s 9.999e10 -> 99990000000.0 %s 99999999999 -> 99999999999.0 +%s 99999999999.9 -> 99999999999.9 +%s 99999999999.99 -> 1e+11 %s 1e11 -> 1e+11 %s 1e12 -> 1e+12 diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py index 91ed054..fb6daaf 100644 --- a/Lib/test/test_float.py +++ b/Lib/test/test_float.py @@ -328,6 +328,11 @@ class FormatTestCase(unittest.TestCase): self.assertEqual(fmt % float(arg), rhs) self.assertEqual(fmt % -float(arg), '-' + rhs) + def test_issue5864(self): + self.assertEquals(format(123.456, '.4'), '123.5') + self.assertEquals(format(1234.56, '.4'), '1.235e+03') + self.assertEquals(format(12345.6, '.4'), '1.235e+04') + class ReprTestCase(unittest.TestCase): def test_repr(self): floats_file = open(os.path.join(os.path.split(__file__)[0], |