Esempio n. 1
0
def test_parse_int_success():
    v = Value(type_name="int", strict=False)

    res = v.parse_int("1")
    assert res == 1

    res = v.parse_int("1.0")
    assert res == 1

    res = v.parse_int("1,1")
    assert res == None

    res = v.parse_int("1,a")
    assert res == None

    res = v.parse_int("1.a")
    assert res == None

    res = v.parse_int(True)
    assert res == 1

    res = v.parse_int(False)
    assert res == 0

    res = v.parse_int(1)
    assert res == 1

    res = v.parse_int(1.2)
    assert res == None
Esempio n. 2
0
def test_parse_int_not_srtict_failure():
    v = Value(type_name="int", strict=False)
    res = v.parse_int("2a")

    assert res is None
    assert v.is_valid is False
Esempio n. 3
0
def test_parse_int_strict_failure():
    v = Value(type_name="int", strict=True)
    with pytest.raises(exc.IntError):
        v.parse_int("2a")