55import sys
66from collections import namedtuple
77from types import ModuleType
8- from typing import Any , Dict , List , Set
8+ from typing import Any , Dict , List , Set , Tuple
99
1010import pytest
1111
2929
3030
3131class TestCases :
32- def __init__ (self , path , services : Set [str ], xfail : Set [str ]):
32+ def __init__ (
33+ self ,
34+ path ,
35+ services : Set [str ],
36+ xfail : Set [str ],
37+ ):
3338 _all = set (get_directories (path )) - {"__pycache__" }
3439 _services = services
3540 _messages = (_all - services ) - {"__pycache__" }
@@ -175,15 +180,18 @@ def test_message_json(repeat, test_data: TestData) -> None:
175180 plugin_module , _ , json_data = test_data
176181
177182 for _ in range (repeat ):
178- for json_sample in json_data :
183+ for sample in json_data :
184+ if sample .belongs_to (test_input_config .non_symmetrical_json ):
185+ continue
186+
179187 message : betterproto .Message = plugin_module .Test ()
180188
181- message .from_json (json_sample )
189+ message .from_json (sample . json )
182190 message_json = message .to_json (0 )
183191
184- assert dict_replace_nans (json .loads (message_json )) == dict_replace_nans (
185- json .loads (json_sample )
186- )
192+ assert dict_replace_nans (json .loads (message_json )) == dict_replace_nans (
193+ json .loads (sample . json )
194+ )
187195
188196
189197@pytest .mark .parametrize ("test_data" , test_cases .services , indirect = True )
@@ -195,13 +203,13 @@ def test_service_can_be_instantiated(test_data: TestData) -> None:
195203def test_binary_compatibility (repeat , test_data : TestData ) -> None :
196204 plugin_module , reference_module , json_data = test_data
197205
198- for json_sample in json_data :
199- reference_instance = Parse (json_sample , reference_module ().Test ())
206+ for sample in json_data :
207+ reference_instance = Parse (sample . json , reference_module ().Test ())
200208 reference_binary_output = reference_instance .SerializeToString ()
201209
202210 for _ in range (repeat ):
203211 plugin_instance_from_json : betterproto .Message = (
204- plugin_module .Test ().from_json (json_sample )
212+ plugin_module .Test ().from_json (sample . json )
205213 )
206214 plugin_instance_from_binary = plugin_module .Test .FromString (
207215 reference_binary_output
0 commit comments