Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tests/test_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Foo(betterproto.Message):
assert betterproto.serialized_on_wire(foo.bar) is False

# Serialized after setting something
foo.bar.baz = 1
foo.bar = Bar(baz=1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing all this is a regression if this PR breaks this

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that isn't great. My PR would break lazy initialization. If you want to keep that, I have to think of another implementation. But lazy initialization also isn't in the google implementation, so I thought it wouldn't be important.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well breaking things isn't good. I know how this can be fixed it's been discussed before but it involves every field having a serialized attribute or similar.

assert betterproto.serialized_on_wire(foo.bar) is True

# Still has it after setting the default value
Expand Down Expand Up @@ -130,7 +130,7 @@ class Foo(betterproto.Message):
assert foo.bar == 0
assert betterproto.which_one_of(foo, "group1")[0] == "baz"

foo.sub.val = 1
foo.sub = Sub(val=1)
assert betterproto.serialized_on_wire(foo.sub)

foo.abc = "test"
Expand Down Expand Up @@ -348,7 +348,7 @@ def test_recursive_message_defaults():
assert msg != RecursiveMessage(
name="bob", intermediate=Intermediate(42), child=RecursiveMessage(name="jude")
)
msg.child.child.name = "jude"
msg.child = RecursiveMessage(child=RecursiveMessage(name="jude"))
assert msg == RecursiveMessage(
name="bob",
intermediate=Intermediate(42),
Expand Down