Fix is_set for optional proto3 fields
This commit is contained in:
committed by
GitHub
parent
6f7d706a8e
commit
3ca092a724
@@ -517,3 +517,15 @@ def test_copyability():
|
||||
assert spam == deepcopied
|
||||
assert spam is not deepcopied
|
||||
assert spam.baz is not deepcopied.baz
|
||||
|
||||
|
||||
def test_is_set():
|
||||
@dataclass
|
||||
class Spam(betterproto.Message):
|
||||
foo: bool = betterproto.bool_field(1)
|
||||
bar: Optional[int] = betterproto.int32_field(2, optional=True)
|
||||
|
||||
assert not Spam().is_set("foo")
|
||||
assert not Spam().is_set("bar")
|
||||
assert Spam(foo=True).is_set("foo")
|
||||
assert Spam(foo=True, bar=0).is_set("bar")
|
||||
|
Reference in New Issue
Block a user