summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_decimal.py
diff options
context:
space:
mode:
authorEric Smith <eric@trueblade.com>2010-11-25 16:08:06 (GMT)
committerEric Smith <eric@trueblade.com>2010-11-25 16:08:06 (GMT)
commit984bb58000df9cdba438c7ecb0bae5ad67878696 (patch)
tree87077ab2bbe949b5241ed9db5f2073572094ffde /Lib/test/test_decimal.py
parentc1d98d685032dd831ced32463b3f88cce6af4067 (diff)
downloadcpython-984bb58000df9cdba438c7ecb0bae5ad67878696.zip
cpython-984bb58000df9cdba438c7ecb0bae5ad67878696.tar.gz
cpython-984bb58000df9cdba438c7ecb0bae5ad67878696.tar.bz2
Issue #7094: Add alternate ('#') flag to __format__ methods for float, complex and Decimal. Allows greater control over when decimal points appear. Added to make transitioning from %-formatting easier. '#g' still has a problem with Decimal which I'll fix soon.
Diffstat (limited to 'Lib/test/test_decimal.py')
-rw-r--r--Lib/test/test_decimal.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py
index 611ef55..3036170 100644
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -818,6 +818,18 @@ class DecimalFormatTest(unittest.TestCase):
# issue 6850
('a=-7.0', '0.12345', 'aaaa0.1'),
+
+ # Issue 7094: Alternate formatting (specified by #)
+ ('.0e', '1.0', '1e+0'),
+ ('#.0e', '1.0', '1.e+0'),
+ ('.0f', '1.0', '1'),
+ ('#.0f', '1.0', '1.'),
+ ('g', '1.1', '1.1'),
+ ('#g', '1.1', '1.1'),
+ ('.0g', '1', '1'),
+ ('#.0g', '1', '1.'),
+ ('.0%', '1.0', '100%'),
+ ('#.0%', '1.0', '100.%'),
]
for fmt, d, result in test_values:
self.assertEqual(format(Decimal(d), fmt), result)