From d674fb80705151badc2dfc7d6d9902bc0c2468cd Mon Sep 17 00:00:00 2001 From: Jeff Dairiki Date: Sat, 16 Sep 2023 09:08:23 -0700 Subject: [PATCH] fix: we do care about the order of Union fields See https://github.com/lovasoa/marshmallow_dataclass/pull/246#issuecomment-1722204048 --- tests/test_field_for_schema.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/tests/test_field_for_schema.py b/tests/test_field_for_schema.py index 2c7cada..6617c76 100644 --- a/tests/test_field_for_schema.py +++ b/tests/test_field_for_schema.py @@ -76,17 +76,10 @@ def _assertAttrsEqual(self, a, b, msg=None): # TestCase.assertSequenceEqual tests item equality with __eq__. # (It doesn't dispatch to an assert* method based on the item type.) # So we'll do the comparison ourself using assertEqual. - - if type(a).__name__ == "Union" and attr == "union_fields": - # We don't care about the order of the union fields. - # Sort before comparing. - value_a = sorted(value_a, key=repr) - value_b = sorted(value_b, key=repr) - for v1, v2 in zip(value_a, value_b): self.assertEqual(v1, v2, msg) else: - self.assertEqual(value_a, value_b) + self.assertEqual(value_a, value_b, msg) def test_int(self): self.assertFieldsEqual(