Ejemplo n.º 1
0
def test_nonetype():
    with pytest.raises(TypeError):
        Fixed(None)
Ejemplo n.º 2
0
def test_gt():
    assert Fixed("2 ether") > "1 ether"
    with pytest.raises(TypeError):
        Fixed("2.0") > 1.0
Ejemplo n.º 3
0
def test_ge():
    assert Fixed("2 ether") >= "1 ether"
    assert Fixed("2 ether") >= "2 ether"
    with pytest.raises(TypeError):
        Fixed("2.0") >= 2.0
Ejemplo n.º 4
0
def test_lt():
    assert Fixed("1 ether") < "2 ether"
    with pytest.raises(TypeError):
        Fixed("1.0") < 1.1
Ejemplo n.º 5
0
def test_le():
    assert Fixed("1 ether") <= "2 ether"
    assert Fixed("1 ether") <= "1 ether"
    with pytest.raises(TypeError):
        Fixed("1.0") <= 1.1
Ejemplo n.º 6
0
def test_eq():
    assert Fixed("1") == 1
    assert not Fixed("123") == "obviously not a number"
    with pytest.raises(TypeError):
        Fixed("1.0") == 1.0
Ejemplo n.º 7
0
def test_ne():
    assert Fixed("1") != 2
    assert Fixed("123") != "obviously not a number"
    with pytest.raises(TypeError):
        Fixed("1.0") != 1.1
Ejemplo n.º 8
0
def test_string_with_unit():
    assert Fixed("3.66 ether") == 3660000000000000000
    assert Fixed("89.006 gwei") == 89006000000
Ejemplo n.º 9
0
def test_type():
    assert type(Fixed(12)) is Fixed
Ejemplo n.º 10
0
def test_str():
    assert Fixed("1000.123456789123456789") == Decimal(
        "1000.123456789123456789")
Ejemplo n.º 11
0
def test_hexstr():
    assert Fixed("0xff") == 255
Ejemplo n.º 12
0
def test_int():
    assert Fixed(1000) == 1000
Ejemplo n.º 13
0
def test_float():
    with pytest.raises(TypeError):
        Fixed(1.99)
Ejemplo n.º 14
0
def test_scientific_notation():
    assert Fixed("8.32e26") == 832000000000000000000000000
Ejemplo n.º 15
0
def test_bytes():
    assert Fixed(b"\xff") == 255
Ejemplo n.º 16
0
def test_success():
    assert to_decimal(123) == 123
    assert to_decimal("-3.1337") == Decimal("-3.1337")
    assert to_decimal("1 ether") == 1000000000000000000
    assert to_decimal(Decimal(42)) == 42
    assert to_decimal(Fixed(6)) == "6"