mirror of
https://github.com/python/cpython.git
synced 2025-10-18 04:38:07 +00:00
Issue #6595: Allow Decimal constructor to accept non-European decimal digits, as recommended by the specification.
This commit is contained in:
parent
642d96a647
commit
345adc43a3
4 changed files with 28 additions and 20 deletions
|
@ -425,9 +425,6 @@ class DecimalExplicitConstructionTest(unittest.TestCase):
|
|||
self.assertEqual(str(Decimal('1.3E4 \n')), '1.3E+4')
|
||||
self.assertEqual(str(Decimal(' -7.89')), '-7.89')
|
||||
|
||||
#but alternate unicode digits should not
|
||||
self.assertEqual(str(Decimal('\uff11')), 'NaN')
|
||||
|
||||
def test_explicit_from_tuples(self):
|
||||
|
||||
#zero
|
||||
|
@ -534,6 +531,15 @@ class DecimalExplicitConstructionTest(unittest.TestCase):
|
|||
d = nc.create_decimal(prevdec)
|
||||
self.assertEqual(str(d), '5.00E+8')
|
||||
|
||||
def test_unicode_digits(self):
|
||||
test_values = {
|
||||
'\uff11': '1',
|
||||
'\u0660.\u0660\u0663\u0667\u0662e-\u0663' : '0.0000372',
|
||||
'-nan\u0c68\u0c6a\u0c66\u0c66' : '-NaN2400',
|
||||
}
|
||||
for input, expected in test_values.items():
|
||||
self.assertEqual(str(Decimal(input)), expected)
|
||||
|
||||
|
||||
class DecimalImplicitConstructionTest(unittest.TestCase):
|
||||
'''Unit tests for Implicit Construction cases of Decimal.'''
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue