Beispiel #1
0
def test_converts_floats_to_decimals_exactly():
    dec = as_decimal(24.390015)

    # due to float imprecision, will be 24.39001599999...
    assert dec != Decimal(24.390015)

    # will be precisely 24.390015
    assert dec == Decimal('24.390015')
Beispiel #2
0
def test_parses_strings():
    dec = as_decimal('12.345')

    assert dec == Decimal('12.345')
Beispiel #3
0
def test_handles_None():
    assert as_decimal(None) is None
Beispiel #4
0
def test_handles_empty_strings():
    assert as_decimal("") is None
Beispiel #5
0
def test_handles_0():
    assert as_decimal(0.0) == Decimal("0.0")
Beispiel #6
0
def test_parses_strings():
    assert as_decimal("12.345") == Decimal("12.345")