예제 #1
0
def test_make_field_value_error(number: int, name: str, type_: Any, value: Any):
    _, field_ = make_field(number, name, type_)
    assert field_.name == name
    with raises(ValueError):
        field_.validate(value)
예제 #2
0
def test_make_field_key_error(type_: Any):
    with raises(KeyError):
        make_field(1, 'a', type_)
예제 #3
0
def test_make_field(number: int, name: str, type_: Any, value: Any, expected: bytes):
    _, field_ = make_field(number, name, type_)
    assert field_.name == name
    field_.validate(value)
    assert field_.dumps(value) == expected
예제 #4
0
def test_make_field_key_error(type_: Any):
    with raises(KeyError):
        make_field(1, 'a', type_)
예제 #5
0
def test_make_field_value_error(number: int, name: str, type_: Any,
                                value: Any):
    _, field_ = make_field(number, name, type_)
    assert field_.name == name
    with raises(ValueError):
        field_.validate(value)
예제 #6
0
def test_make_field(number: int, name: str, type_: Any, value: Any,
                    expected: bytes):
    _, field_ = make_field(number, name, type_)
    assert field_.name == name
    field_.validate(value)
    assert field_.dumps(value) == expected
예제 #7
0
def test_make_field_type_error(type_: Any):
    with raises(TypeError):
        make_field(1, 'a', type_)