Skip to content

Commit

Permalink
tests: add an encoding roundtrip for Struct
Browse files Browse the repository at this point in the history
  • Loading branch information
woodruffw committed Feb 25, 2024
1 parent 5666393 commit ef28349
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/betterproto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
hybridmethod,
)


if TYPE_CHECKING:
from _typeshed import (
SupportsRead,
Expand Down
5 changes: 5 additions & 0 deletions tests/test_struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ def test_struct_roundtrip():
assert struct_from_dict.to_dict() == data
assert struct_from_dict.to_json() == data_json

struct_from_proto = Struct().parse(bytes(struct_from_dict))
assert struct_from_proto.fields == data
assert struct_from_proto.to_dict() == data
assert struct_from_proto.to_json() == data_json

struct_from_json = Struct().from_json(data_json)
assert struct_from_json.fields == data
assert struct_from_json.to_dict() == data
Expand Down

0 comments on commit ef28349

Please sign in to comment.