Skip to content

Commit

Permalink
Added values to differing dict values
Browse files Browse the repository at this point in the history
  • Loading branch information
rshk committed Jul 23, 2014
1 parent 1b0d3be commit 4bb491f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions differ/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ def _are_both(left, right, types):


def _compare_dicts(left, right):
left_only = []
right_only = []
left_only = {}
right_only = {}
differences = {}
equal = []

all_keys = set(left.keys()).union(set(right.keys()))
for key in all_keys:
if key not in left:
right_only.append(key)
right_only[key] = right[key]
elif key not in right:
left_only.append(key)
left_only[key] = left[key]
else:
diff = compare_objects(left[key], right[key])
if diff['distance'] == 0:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_compare_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def test_compare_simple_dicts():

diff = compare_objects(dict1, dict2)
assert diff['distance'] == 3/4
assert diff['added'] == ['ddd']
assert diff['removed'] == ['aaa']
assert diff['added'] == {'ddd': 'D'}
assert diff['removed'] == {'aaa': 'A'}
assert diff['changed'] == ['ccc']
assert diff['equal'] == ['bbb']
assert diff['changes'] == {
Expand Down

0 comments on commit 4bb491f

Please sign in to comment.