Prevent users from creating messages with wrong parameters when pydantic is used (#615)
This commit is contained in:
7
tests/inputs/invalid_field/invalid_field.proto
Normal file
7
tests/inputs/invalid_field/invalid_field.proto
Normal file
@@ -0,0 +1,7 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package invalid_field;
|
||||
|
||||
message Test {
|
||||
int32 x = 1;
|
||||
}
|
17
tests/inputs/invalid_field/test_invalid_field.py
Normal file
17
tests/inputs/invalid_field/test_invalid_field.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import pytest
|
||||
|
||||
|
||||
def test_invalid_field():
|
||||
from tests.output_betterproto.invalid_field import Test
|
||||
|
||||
with pytest.raises(TypeError):
|
||||
Test(unknown_field=12)
|
||||
|
||||
|
||||
def test_invalid_field_pydantic():
|
||||
from pydantic import ValidationError
|
||||
|
||||
from tests.output_betterproto_pydantic.invalid_field import Test
|
||||
|
||||
with pytest.raises(ValidationError):
|
||||
Test(unknown_field=12)
|
Reference in New Issue
Block a user