-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent users from creating messages with wrong parameters when pydan…
…tic is used (#615)
- Loading branch information
1 parent
efaef50
commit 8fdcb38
Showing
6 changed files
with
799 additions
and
886 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
syntax = "proto3"; | ||
|
||
package invalid_field; | ||
|
||
message Test { | ||
int32 x = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |