Skip to content

Commit

Permalink
blackening
Browse files Browse the repository at this point in the history
  • Loading branch information
nixjdm committed Apr 5, 2023
1 parent 6bd9fea commit fa843f2
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ def __hash__(self):
({fun_five: 1}, -5, {"match_with": "hash"}, 1),
({"foo!": 1}, "foo!", {"match_with": "equality"}, 1),
({1: 1}, 0, {"match_with": "equality"}, []),
({'alias': 'foo'}, '^a', {"match_with": "regex"}, "foo"),
({'alias': 'foo'}, '^a...s$', {"match_with": "regex"}, "foo"),
({"not a hit": {'alias': 'foo'}}, ["**", '^a'], {"match_with": "regex"}, "foo"),
({"alias": "foo"}, "^a", {"match_with": "regex"}, "foo"),
({"alias": "foo"}, "^a...s$", {"match_with": "regex"}, "foo"),
({"not a hit": {"alias": "foo"}}, ["**", "^a"], {"match_with": "regex"}, "foo"),
({"xd": 1}, "xd", {"match_with": "regex"}, 1),
({"xd": 1}, "?d", {"match_with": "regex"}, re.error), # glob, not valid regex
({"xd": 1}, "?d", {}, 1),
Expand Down Expand Up @@ -104,18 +104,19 @@ def test_paths_to_key(obj, key, result):
else:
assert list(paths_to_key(obj, key)) == result


# Basic tests of various match styles
@pytest.mark.parametrize(
"obj, key, kwargs, result",
[
({'alias': 'foo'}, 'a*', {"match_with": "glob"}, [['alias']]),
({'alias': 'foo'}, '^a', {"match_with": "regex"}, [['alias']]),
({'alias': 'foo'}, '^a', {"match_with": "equality"}, []),
({'alias': 'foo'}, 'alias', {"match_with": "equality"}, [['alias']]),
({'alias': 'foo'}, '?lias', {"match_with": "regex"}, re.error),
({'alias': {'blias': 'foo'}}, '^a', {"match_with": "glob+regex"}, [['alias']]),
({'alias': {'blias': 'foo'}}, '*s', {"match_with": "glob+regex"}, [['alias', 'blias'], ['alias']]),
({1: 'foo'}, 1, {"match_with": "hash"}, [[1]]),
({"alias": "foo"}, "a*", {"match_with": "glob"}, [["alias"]]),
({"alias": "foo"}, "^a", {"match_with": "regex"}, [["alias"]]),
({"alias": "foo"}, "^a", {"match_with": "equality"}, []),
({"alias": "foo"}, "alias", {"match_with": "equality"}, [["alias"]]),
({"alias": "foo"}, "?lias", {"match_with": "regex"}, re.error),
({"alias": {"blias": "foo"}}, "^a", {"match_with": "glob+regex"}, [["alias"]]),
({"alias": {"blias": "foo"}}, "*s", {"match_with": "glob+regex"}, [["alias", "blias"], ["alias"]]),
({1: "foo"}, 1, {"match_with": "hash"}, [[1]]),
],
)
def test_paths_to_key_styles(obj, key, kwargs, result):
Expand All @@ -125,6 +126,7 @@ def test_paths_to_key_styles(obj, key, kwargs, result):
else:
assert list(paths_to_key(obj, key, **kwargs)) == result


@pytest.mark.parametrize(
"obj, value, result",
[
Expand Down

0 comments on commit fa843f2

Please sign in to comment.