summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorXtreak <tir.karthi@gmail.com>2019-01-07 15:09:14 (GMT)
committerVictor Stinner <vstinner@redhat.com>2019-01-07 15:09:14 (GMT)
commit3f7983a25a3d19779283c707fbdd5bc91b1587ef (patch)
treebe67585aae69489545dcccfa2938a3274b811b7e /Lib/test
parenta0bb51e44cd43a7d2836a96a3804162203e44514 (diff)
downloadcpython-3f7983a25a3d19779283c707fbdd5bc91b1587ef.zip
cpython-3f7983a25a3d19779283c707fbdd5bc91b1587ef.tar.gz
cpython-3f7983a25a3d19779283c707fbdd5bc91b1587ef.tar.bz2
bpo-35560: Remove assertion from format(float, "n") (GH-11288)
Fix an assertion error in format() in debug build for floating point formatting with "n" format, zero padding and small width. Release build is not impacted. Patch by Karthikeyan Singaravelan.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_float.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py
index 06ea90c..49c1fbc 100644
--- a/Lib/test/test_float.py
+++ b/Lib/test/test_float.py
@@ -701,6 +701,25 @@ class FormatTestCase(unittest.TestCase):
self.assertEqual(format(1234.56, '.4'), '1.235e+03')
self.assertEqual(format(12345.6, '.4'), '1.235e+04')
+ def test_issue35560(self):
+ self.assertEqual(format(123.0, '00'), '123.0')
+ self.assertEqual(format(123.34, '00f'), '123.340000')
+ self.assertEqual(format(123.34, '00e'), '1.233400e+02')
+ self.assertEqual(format(123.34, '00g'), '123.34')
+ self.assertEqual(format(123.34, '00.10f'), '123.3400000000')
+ self.assertEqual(format(123.34, '00.10e'), '1.2334000000e+02')
+ self.assertEqual(format(123.34, '00.10g'), '123.34')
+ self.assertEqual(format(123.34, '01f'), '123.340000')
+
+ self.assertEqual(format(-123.0, '00'), '-123.0')
+ self.assertEqual(format(-123.34, '00f'), '-123.340000')
+ self.assertEqual(format(-123.34, '00e'), '-1.233400e+02')
+ self.assertEqual(format(-123.34, '00g'), '-123.34')
+ self.assertEqual(format(-123.34, '00.10f'), '-123.3400000000')
+ self.assertEqual(format(-123.34, '00.10f'), '-123.3400000000')
+ self.assertEqual(format(-123.34, '00.10e'), '-1.2334000000e+02')
+ self.assertEqual(format(-123.34, '00.10g'), '-123.34')
+
class ReprTestCase(unittest.TestCase):
def test_repr(self):
floats_file = open(os.path.join(os.path.split(__file__)[0],