Prevent users from creating messages with wrong parameters when pydantic is used (#615)

This commit is contained in:
Adrien
2024-09-12 19:34:47 +02:00
committed by GitHub
parent efaef5095c
commit 8fdcb381b7
6 changed files with 797 additions and 884 deletions

View File

@@ -0,0 +1,7 @@
syntax = "proto3";
package invalid_field;
message Test {
int32 x = 1;
}

View 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)