@@ -128,7 +128,7 @@ def test_oneOf_array_of_integers(self):
128128 # test to_json, to_dict method
129129 json_str = '[12,34,56]'
130130 p = petstore_api .Color .from_json (json_str )
131- self .assertEqual (p .to_json (), " [12, 34, 56]" )
131+ self .assertEqual (json . loads ( p .to_json ()), [12 , 34 , 56 ])
132132 self .assertEqual (p .to_dict (), [12 , 34 , 56 ])
133133
134134 # test nullable
@@ -145,12 +145,12 @@ def test_oneof_nested_from_enum_string(self):
145145 assert oneof_enum is not None
146146 nested = petstore_api .WithNestedOneOf (size = 1 , nested_oneof_enum_string = oneof_enum )
147147 # test to_json
148- self .assertEqual (nested .to_json (), ' {"size": 1, "nested_oneof_enum_string": "a"}' )
148+ self .assertEqual (json . loads ( nested .to_json ()), {"size" : 1 , "nested_oneof_enum_string" : "a" })
149149
150150 def test_oneof_nested_from_json (self ):
151151 nested = petstore_api .WithNestedOneOf .from_json ('{"size": 1, "nested_oneof_enum_string": "c"}' )
152152 assert nested is not None
153- self .assertEqual (nested .to_json (), ' {"size": 1, "nested_oneof_enum_string": "c"}' )
153+ self .assertEqual (json . loads ( nested .to_json ()), {"size" : 1 , "nested_oneof_enum_string" : "c" })
154154
155155 def test_oneof_nested_from_dict (self ):
156156 nested = petstore_api .WithNestedOneOf .from_dict ({"size" : 1 , "nested_oneof_enum_string" : "c" })
@@ -217,9 +217,9 @@ def test_oneOf(self):
217217 self .assertEqual ("null" , new_pig .to_json ())
218218 self .assertEqual (None , new_pig .actual_instance )
219219 new_pig2 = petstore_api .Pig (actual_instance = bp )
220- self .assertEqual (' {"className": "BasquePig", "color": "red"}' , new_pig2 .to_json ())
220+ self .assertEqual ({"className" : "BasquePig" , "color" : "red" }, json . loads ( new_pig2 .to_json () ))
221221 new_pig3 = petstore_api .Pig (bp )
222- self .assertEqual (' {"className": "BasquePig", "color": "red"}' , new_pig3 .to_json ())
222+ self .assertEqual ({"className" : "BasquePig" , "color" : "red" }, json . loads ( new_pig3 .to_json () ))
223223 try :
224224 new_pig4 = petstore_api .Pig (bp , actual_instance = bp )
225225 except ValueError as e :
@@ -277,11 +277,11 @@ def test_oneOf(self):
277277 # self.assertEqual(str(e), error_message)
278278
279279 # test to_json
280- self .assertEqual (p .to_json (), ' {"className": "BasquePig", "color": "red"}' )
280+ self .assertEqual (json . loads ( p .to_json ()), {"className" : "BasquePig" , "color" : "red" })
281281
282282 # test nested property
283283 nested = petstore_api .WithNestedOneOf (size = 1 , nested_pig = p )
284- self .assertEqual (nested .to_json (), ' {"size": 1, "nested_pig": {"className": "BasquePig", "color": "red"}}' )
284+ self .assertEqual (json . loads ( nested .to_json ()), {"size" : 1 , "nested_pig" : {"className" : "BasquePig" , "color" : "red" }})
285285
286286 nested_json = nested .to_json ()
287287 nested2 = petstore_api .WithNestedOneOf .from_json (nested_json )
@@ -330,11 +330,11 @@ def test_anyOf(self):
330330 self .assertIn ("No match found when deserializing the JSON string into AnyOfPig with anyOf schemas: BasquePig, DanishPig" , str (e ))
331331
332332 # test to_json
333- self .assertEqual (p .to_json (), ' {"className": "BasquePig", "color": "red"}' )
333+ self .assertEqual (json . loads ( p .to_json ()), {"className" : "BasquePig" , "color" : "red" })
334334
335335 def test_inheritance (self ):
336336 dog = petstore_api .Dog (breed = "bulldog" , className = "dog" , color = "white" )
337- self .assertEqual (dog .to_json (), ' {"className": "dog", "color": "white", "breed": "bulldog"}' )
337+ self .assertEqual (json . loads ( dog .to_json ()), {"className" : "dog" , "color" : "white" , "breed" : "bulldog" })
338338 self .assertEqual (dog .to_dict (), {'breed' : 'bulldog' , 'className' :
339339 'dog' , 'color' : 'white' })
340340 dog2 = petstore_api .Dog .from_json (dog .to_json ())
@@ -360,7 +360,7 @@ def test_list(self):
360360 self .assertTrue ("Input should be a valid string" in str (e ))
361361
362362 l = petstore_api .ListClass (** {"123-list" : "bulldog" }) # type: ignore
363- self .assertEqual (l .to_json (), '{" 123-list": " bulldog"}' )
363+ self .assertEqual (json . loads ( l .to_json ()), { ' 123-list' : ' bulldog' } )
364364 self .assertEqual (l .to_dict (), {'123-list' : 'bulldog' })
365365
366366 l2 = petstore_api .ListClass .from_json (l .to_json ())
@@ -372,22 +372,22 @@ def test_enum_ref_property(self):
372372 # test enum ref property
373373 # test to_json
374374 d = petstore_api .OuterObjectWithEnumProperty (value = petstore_api .OuterEnumInteger .NUMBER_1 )
375- self .assertEqual (d .to_json (), ' {"value": 1}' )
375+ self .assertEqual (json . loads ( d .to_json ()), {"value" : 1 })
376376 d2 = petstore_api .OuterObjectWithEnumProperty (value = petstore_api .OuterEnumInteger .NUMBER_1 , str_value = petstore_api .OuterEnum .DELIVERED )
377- self .assertEqual (d2 .to_json (), ' {"str_value": "delivered", "value": 1}' )
377+ self .assertEqual (json . loads ( d2 .to_json ()), {"str_value" : "delivered" , "value" : 1 })
378378 # test from_json (round trip)
379379 d3 = petstore_api .OuterObjectWithEnumProperty .from_json (d2 .to_json ())
380380 assert d3 is not None
381381 self .assertEqual (d3 .str_value , petstore_api .OuterEnum .DELIVERED )
382382 self .assertEqual (d3 .value , petstore_api .OuterEnumInteger .NUMBER_1 )
383- self .assertEqual (d3 .to_json (), ' {"str_value": "delivered", "value": 1}' )
383+ self .assertEqual (json . loads ( d3 .to_json ()), {"str_value" : "delivered" , "value" : 1 })
384384 d4 = petstore_api .OuterObjectWithEnumProperty (value = petstore_api .OuterEnumInteger .NUMBER_1 , str_value = None )
385- self .assertEqual (d4 .to_json (), ' {"value": 1, "str_value": null}' )
385+ self .assertEqual (json . loads ( d4 .to_json ()), {"value" : 1 , "str_value" : None } )
386386 d5 = petstore_api .OuterObjectWithEnumProperty (value = petstore_api .OuterEnumInteger .NUMBER_1 )
387387 self .assertEqual (d5 .model_fields_set , {'value' })
388388 d5 .str_value = None # set None explicitly
389389 self .assertEqual (d5 .model_fields_set , {'value' , 'str_value' })
390- self .assertEqual (d5 .to_json (), ' {"value": 1, "str_value": null}' )
390+ self .assertEqual (json . loads ( d5 .to_json ()), {"value" : 1 , "str_value" : None } )
391391
392392 def test_valdiator (self ):
393393 # test regular expression
@@ -482,7 +482,7 @@ def test_additional_properties(self):
482482 self .assertNotEqual (id (pet_ap .additional_properties ), id (pet_ap2 .additional_properties ))
483483
484484 pet_ap .additional_properties ["something-new" ] = "haha"
485- self .assertEqual (pet_ap .to_json (), ' {"id": 1, "name": "test name", "photoUrls": ["string"], "status": "available", "something-new": "haha"}' )
485+ self .assertEqual (json . loads ( pet_ap .to_json ()), {"id" : 1 , "name" : "test name" , "photoUrls" : ["string" ], "status" : "available" , "something-new" : "haha" })
486486 self .assertEqual (type (pet_ap2 .additional_properties ), dict )
487487 self .assertNotEqual (id (pet_ap .additional_properties ), id (pet_ap2 .additional_properties ))
488488 self .assertEqual (pet_ap .additional_properties ["something-new" ], "haha" )
@@ -507,10 +507,10 @@ def test_additional_properties(self):
507507
508508 def test_nullable (self ):
509509 h = petstore_api .HealthCheckResult (NullableMessage = "Not none" )
510- self .assertEqual (h .to_json (), ' {"NullableMessage": "Not none"}' )
510+ self .assertEqual (json . loads ( h .to_json ()), {"NullableMessage" : "Not none" })
511511
512512 h .nullable_message = None
513- self .assertEqual (h .to_json (), ' {"NullableMessage": null}' )
513+ self .assertEqual (json . loads ( h .to_json ()), {"NullableMessage" : None } )
514514
515515 #import json
516516 #dictionary ={
@@ -585,7 +585,7 @@ def test_map_of_array_of_model(self):
585585 t = petstore_api .Tag (id = 123 , name = "tag name" )
586586 a .shop_id_to_org_online_lip_map = {"somekey" : [t ]}
587587 self .assertEqual (a .to_dict (), {'shopIdToOrgOnlineLipMap' : {'somekey' : [{'id' : 123 , 'name' : 'tag name' }]}})
588- self .assertEqual (a .to_json (), '{" shopIdToOrgOnlineLipMap" : {" somekey" : [{"id" : 123, " name": " tag name" }]}}' )
588+ self .assertEqual (json . loads ( a .to_json ()), { ' shopIdToOrgOnlineLipMap' : {' somekey' : [{'id' : 123 , ' name' : ' tag name' }]}})
589589 a2 = petstore_api .MapOfArrayOfModel .from_dict (a .to_dict ())
590590 assert a2 is not None
591591 self .assertEqual (a .to_dict (), a2 .to_dict ())
@@ -595,7 +595,7 @@ def test_array_of_array_of_model(self):
595595 t = petstore_api .Tag (id = 123 , name = "tag name" )
596596 a .another_property = [[t ]]
597597 self .assertEqual (a .to_dict (), {'another_property' : [[ {'id' : 123 , 'name' : 'tag name' } ]]})
598- self .assertEqual (a .to_json (), '{" another_property" : [[{"id" : 123, " name": " tag name"} ]]}' )
598+ self .assertEqual (json . loads ( a .to_json ()), { ' another_property' : [[ { 'id' : 123 , ' name' : ' tag name' } ]]})
599599 a2 = petstore_api .ArrayOfArrayOfModel .from_dict (a .to_dict ())
600600 assert a2 is not None
601601 self .assertEqual (a .to_dict (), a2 .to_dict ())
@@ -617,7 +617,7 @@ def test_allof(self):
617617 model = petstore_api .Tiger .from_json ('{"skill": "none", "type": "tiger", "info": {"name": "creature info"}}' )
618618 # shouldn't throw NameError
619619 assert model is not None
620- self .assertEqual (model .to_json (), ' {"skill": "none", "type": "tiger", "info": {"name": "creature info"}}' )
620+ self .assertEqual (json . loads ( model .to_json ()), {"skill" : "none" , "type" : "tiger" , "info" : {"name" : "creature info" }})
621621
622622 def test_allof_circular_imports (self ):
623623 # for issue 18271
@@ -626,8 +626,8 @@ def test_allof_circular_imports(self):
626626 # shouldn't throw ImportError
627627 assert model_a is not None
628628 assert model_b is not None
629- self .assertEqual (model_a .to_json (), ' {"_name": "nameA", "second_circular_all_of_ref": {"name": "nameB"}}' )
630- self .assertEqual (model_b .to_json (), ' {"_name": "nameB", "circular_all_of_ref": {"name": "nameA"}}' )
629+ self .assertEqual (json . loads ( model_a .to_json ()), {"_name" : "nameA" , "second_circular_all_of_ref" : {"name" : "nameB" }})
630+ self .assertEqual (json . loads ( model_b .to_json ()), {"_name" : "nameB" , "circular_all_of_ref" : {"name" : "nameA" }})
631631
632632 def test_allof_discriminator_mapping (self ):
633633 # for issue 18498
@@ -642,17 +642,17 @@ def test_additional_properties(self):
642642 a1 = petstore_api .AdditionalPropertiesAnyType ()
643643 a1 .additional_properties = { "abc" : 123 }
644644 self .assertEqual (a1 .to_dict (), {"abc" : 123 })
645- self .assertEqual (a1 .to_json (), ' {"abc": 123}' )
645+ self .assertEqual (json . loads ( a1 .to_json ()), {"abc" : 123 })
646646
647647 a2 = petstore_api .AdditionalPropertiesObject ()
648648 a2 .additional_properties = { "efg" : 45.6 }
649649 self .assertEqual (a2 .to_dict (), {"efg" : 45.6 })
650- self .assertEqual (a2 .to_json (), ' {"efg": 45.6}' )
650+ self .assertEqual (json . loads ( a2 .to_json ()), {"efg" : 45.6 })
651651
652652 a3 = petstore_api .AdditionalPropertiesWithDescriptionOnly ()
653653 a3 .additional_properties = { "xyz" : 45.6 }
654654 self .assertEqual (a3 .to_dict (), {"xyz" : 45.6 })
655- self .assertEqual (a3 .to_json (), ' {"xyz": 45.6}' )
655+ self .assertEqual (json . loads ( a3 .to_json ()), {"xyz" : 45.6 })
656656
657657class TestUnnamedDictWithAdditionalStringListProperties :
658658 def test_empty_dict (self ):
0 commit comments