This repository was archived by the owner on Feb 23, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -121,6 +121,23 @@ class Squid(proto.Message):
121121 )
122122 assert json1 == '{"name":"Steve"}'
123123
124+ json1 = (
125+ Squid .to_json (s , always_print_fields_with_no_presence = False )
126+ .replace (" " , "" )
127+ .replace ("\n " , "" )
128+ )
129+ assert json1 == '{"name":"Steve"}'
130+
131+ with pytest .raises (
132+ ValueError ,
133+ match = "Arguments.*always_print_fields_with_no_presence.*including_default_value_fields.*must match" ,
134+ ):
135+ Squid .to_json (
136+ s ,
137+ including_default_value_fields = True ,
138+ always_print_fields_with_no_presence = False ,
139+ ).replace (" " , "" ).replace ("\n " , "" )
140+
124141 json2 = Squid .to_json (s ).replace (" " , "" ).replace ("\n " , "" )
125142 assert (
126143 json2 == '{"name":"Steve","massKg":0}' or json2 == '{"massKg":0,"name":"Steve"}'
Original file line number Diff line number Diff line change @@ -267,6 +267,20 @@ class Color(proto.Enum):
267267 expected_dict = {"mass_kg" : 20 }
268268 assert s_dict_2 == expected_dict
269269
270+ s_dict_2 = Squid .to_dict (s_new_2 , always_print_fields_with_no_presence = False )
271+ expected_dict = {"mass_kg" : 20 }
272+ assert s_dict_2 == expected_dict
273+
274+ with pytest .raises (
275+ ValueError ,
276+ match = "Arguments.*always_print_fields_with_no_presence.*including_default_value_fields.*must match" ,
277+ ):
278+ s_dict_2 = Squid .to_dict (
279+ s_new_2 ,
280+ including_default_value_fields = True ,
281+ always_print_fields_with_no_presence = False ,
282+ )
283+
270284 new_s = Squid (s_dict )
271285 assert new_s == s
272286
You can’t perform that action at this time.
0 commit comments