summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_complex.py10
-rw-r--r--Lib/test/test_float.py7
2 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_complex.py b/Lib/test/test_complex.py
index ac19353..1593f7b 100644
--- a/Lib/test/test_complex.py
+++ b/Lib/test/test_complex.py
@@ -445,6 +445,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')
diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py
index fb6daaf..b617fa3 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')