Skip to content
This repository has been archived by the owner on Dec 15, 2020. It is now read-only.

Commit

Permalink
fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackevansevo committed Apr 23, 2017
1 parent 62ccabc commit 5e88a34
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion basic_utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def dict_subset(d: dict, keys, prune=False, default=None):
"""
new = {k: d.get(k, default) for k in keys}
if prune:
return prune(new)
return prune_dict(new)
return new


Expand Down
14 changes: 8 additions & 6 deletions tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,15 @@ def test_get_keys(keys, expected, default):
assert get_keys({"a": 1, "b": 2}, keys, default) == expected


@pytest.mark.parametrize("data, keys, expected, include_missing", [
({'a': 1, 'b': 2, 'c': 3}, ("a", "b"), {'a': 1, 'b': 2}, True),
({'a': 1, 'b': 2}, ("a", "b", "c"), {'a': 1, 'b': 2}, False),
({'a': 1, 'b': 2}, ("a", "b", "c"), {'a': 1, 'b': 2, 'c': None}, True),
@pytest.mark.parametrize("keys, expected, prune, default", [
(('a', 'b', 'c'), {'a': 1, 'b': 2, 'c': 3}, False, None),
(('a', 'b', 'z'), {'a': 1, 'b': 2}, True, None),
(('a', 'b', 'z'), {'a': 1, 'b': 2, 'z': None}, False, None),
(('a', 'b', 'z'), {'a': 1, 'b': 2, 'z': 'Missing'}, False, 'Missing'),
])
def test_dict_subset(data, keys, expected, include_missing):
assert dict_subset(data, keys, include_missing) == expected
def test_dict_subset(keys, expected, prune, default):
d = {'a': 1, 'b': 2, 'c': 3}
assert dict_subset(d, keys, prune, default) == expected


@pytest.mark.parametrize("data, keys, expected", [
Expand Down

0 comments on commit 5e88a34

Please sign in to comment.