Exemplo n.º 1
0
async def test_number_exception():
    """Test number exception."""

    try:
        number("x15.1")
    except (vol.Invalid):
        return

    pytest.fail("Number not throwing exception")
Exemplo n.º 2
0
async def test_number_validator():
    """Test number validator."""

    for value, value_type in [
        (15, int),
        (15.1, float),
        ("15", int),
        ("15.1", float),
        (-15, int),
        (-15.1, float),
        ("-15", int),
        ("-15.1", float),
    ]:
        assert isinstance(number(value), value_type)

    try:
        number("x15.1")
    except (vol.Invalid):
        return
    pytest.fail("Number not throwing exception")
Exemplo n.º 3
0
async def test_number_validator(value, value_type):
    """Test number validator."""

    assert isinstance(number(value), value_type)