Exemplo n.º 1
0
 def test_can_parse_decimals(self):
     self.assertEqual(Decimal('1099.98'),
         numbers.parse_decimal('1,099.98', locale='en_US'))
     self.assertEqual(Decimal('1099.98'),
         numbers.parse_decimal('1.099,98', locale='de'))
     self.assertRaises(numbers.NumberFormatError,
                       lambda: numbers.parse_decimal('2,109,998', locale='de'))
Exemplo n.º 2
0
def test_parse_decimal():
    assert (numbers.parse_decimal('1,099.98', locale='en_US')
            == Decimal('1099.98'))
    assert numbers.parse_decimal('1.099,98', locale='de') == Decimal('1099.98')

    with pytest.raises(numbers.NumberFormatError) as excinfo:
        numbers.parse_decimal('2,109,998', locale='de')
    assert excinfo.value.args[0] == "'2,109,998' is not a valid decimal number"