Skip to content

Commit

Permalink
fix: we do care about the order of Union fields
Browse files Browse the repository at this point in the history
  • Loading branch information
dairiki committed Sep 16, 2023
1 parent e915f08 commit d674fb8
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions tests/test_field_for_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit d674fb8

Please sign in to comment.