Added key sorting to have deterministing string repr of RecursiveDictDiffer objects

This commit is contained in:
Alexandru Bleotu 2017-09-25 13:09:38 -04:00
parent 2d2f094810
commit cdb028b794
2 changed files with 2 additions and 2 deletions

View file

@ -217,7 +217,7 @@ class RecursiveDictDiffer(DictDiffer):
Each inner difference is tabulated two space deeper
'''
changes_strings = []
for p in diff_dict.keys():
for p in sorted(diff_dict.keys()):
if sorted(diff_dict[p].keys()) == ['new', 'old']:
# Some string formatting
old_value = diff_dict[p]['old']

View file

@ -89,7 +89,7 @@ class RecursiveDictDifferTestCase(TestCase):
'a:\n'
' c from 2 to 4\n'
' e from \'old_value\' to \'new_value\'\n'
' g from nothing to \'new_key\'\n'
' f from \'old_key\' to nothing\n'
' g from nothing to \'new_key\'\n'
'h from nothing to \'new_key\'\n'
'i from nothing to None')