コード例 #1
0
def test_sNaN():
    with pytest.raises(ValueError):
        str_to_decimal('sNaN')
コード例 #2
0
 def _maybe_coerce(value: Union[str, Decimal] = None) -> Optional[Decimal]:
     if value is not None:
         if not isinstance(value, Decimal):
             return str_to_decimal(value)
         return value
     return None
コード例 #3
0
def test_Inf():
    with pytest.raises(ValueError):
        str_to_decimal('Inf')
コード例 #4
0
def test_negative_Inf():
    with pytest.raises(ValueError):
        str_to_decimal('-Inf')
コード例 #5
0
def test_str():
    d1 = Decimal('3.3333433434343434343434343434343')
    assert str_to_decimal(str(d1)) == d1
コード例 #6
0
def test_maxlen():
    s = '3.' + '34' * 1000
    with pytest.raises(ValueError):
        str_to_decimal(s)
コード例 #7
0
def test_str_to_decimal_None():
    assert str_to_decimal(None) is None
コード例 #8
0
def test_str_to_decimal_decimals(x):
    assume(x.is_finite())
    assert str_to_decimal(str(x)) == x
コード例 #9
0
ファイル: test_json.py プロジェクト: faust-streaming/faust
def test_NaN():
    with pytest.raises(ValueError):
        str_to_decimal("NaN")
コード例 #10
0
ファイル: test_json.py プロジェクト: faust-streaming/faust
def test_maxlen():
    s = "3." + "34" * 1000
    with pytest.raises(ValueError):
        str_to_decimal(s)
コード例 #11
0
 def _parse_decimal(typ: Type, data: Any) -> Optional[Decimal]:
     if data is None:
         return None
     if isinstance(data, Decimal):
         return data
     return str_to_decimal(cast(str, data))