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)
def test_make_field_key_error(type_: Any): with raises(KeyError): make_field(1, 'a', type_)
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
def test_make_field_type_error(type_: Any): with raises(TypeError): make_field(1, 'a', type_)