When testing https://github.com/Shopify/pyoozie/pull/46, sometimes XML comparisons would fail due to the ordering of lists of dicts (this happens maybe 10% of the time).
...
E 'fork': {'@name': 'fork-00000005',
E - 'path': [{'@start': 'action-00000000'},
E ? ^
E + 'path': [{'@start': 'action-00000001'},
E ? ^
E - {'@start': 'action-00000001'}]},
E ? ^
E + {'@start': 'action-00000000'}]},
E ? ^
...
Solution
This PR refactors xml_to_comparable_dict to convert collections.OrderedDict to a dict in _unorder, and if there's a list, it tries to predictably sort it by recursing through a value's contents and getting a hashable object for each type in _sort_key.
Problem
When testing https://github.com/Shopify/pyoozie/pull/46, sometimes XML comparisons would fail due to the ordering of lists of dicts (this happens maybe 10% of the time).
Solution
This PR refactors
xml_to_comparable_dict
to convertcollections.OrderedDict
to adict
in_unorder
, and if there's a list, it tries to predictably sort it by recursing through a value's contents and getting a hashable object for each type in_sort_key
.cc/ @Shopify/data-acceleration