def test_sNaN(): with pytest.raises(ValueError): str_to_decimal('sNaN')
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
def test_Inf(): with pytest.raises(ValueError): str_to_decimal('Inf')
def test_negative_Inf(): with pytest.raises(ValueError): str_to_decimal('-Inf')
def test_str(): d1 = Decimal('3.3333433434343434343434343434343') assert str_to_decimal(str(d1)) == d1
def test_maxlen(): s = '3.' + '34' * 1000 with pytest.raises(ValueError): str_to_decimal(s)
def test_str_to_decimal_None(): assert str_to_decimal(None) is None
def test_str_to_decimal_decimals(x): assume(x.is_finite()) assert str_to_decimal(str(x)) == x
def test_NaN(): with pytest.raises(ValueError): str_to_decimal("NaN")
def test_maxlen(): s = "3." + "34" * 1000 with pytest.raises(ValueError): str_to_decimal(s)
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))