コード例 #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')
コード例 #2
0
def test_parses_strings():
    dec = as_decimal('12.345')

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