From ef28349ab5ccb914c68a391083516fd2644b0b45 Mon Sep 17 00:00:00 2001 From: William Woodruff Date: Sun, 25 Feb 2024 12:48:42 -0500 Subject: [PATCH 1/2] tests: add an encoding roundtrip for Struct --- src/betterproto/__init__.py | 1 - tests/test_struct.py | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/betterproto/__init__.py b/src/betterproto/__init__.py index da6893db7..68492ffab 100644 --- a/src/betterproto/__init__.py +++ b/src/betterproto/__init__.py @@ -55,7 +55,6 @@ hybridmethod, ) - if TYPE_CHECKING: from _typeshed import ( SupportsRead, diff --git a/tests/test_struct.py b/tests/test_struct.py index f266bc892..905891475 100644 --- a/tests/test_struct.py +++ b/tests/test_struct.py @@ -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 From 281a8b4635b8c9cb31d7d724e3550b2eb4a5766d Mon Sep 17 00:00:00 2001 From: William Woodruff Date: Sun, 25 Feb 2024 12:57:35 -0500 Subject: [PATCH 2/2] lintage --- src/betterproto/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/betterproto/__init__.py b/src/betterproto/__init__.py index 68492ffab..da6893db7 100644 --- a/src/betterproto/__init__.py +++ b/src/betterproto/__init__.py @@ -55,6 +55,7 @@ hybridmethod, ) + if TYPE_CHECKING: from _typeshed import ( SupportsRead,