Python decimal.Overflow() Examples

The following are 1 code examples of decimal.Overflow(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module decimal , or try the search function .
Example #1
Source File: test_utils.py    From cryptotrader with MIT License 5 votes vote down vote up
def test_convert_to(data):
    if abs(data) < Decimal('1e18'):
        number = convert_to.decimal(data)
        assert number - Decimal.from_float(data).quantize(Decimal('0e-9')) < Decimal("1e-8")

    elif abs(data) < Decimal('1e33'):
        with pytest.raises(InvalidOperation):
            convert_to.decimal(data)
    else:
        with pytest.raises(Overflow):
            convert_to.decimal(data)