Skip to content

Commit

Permalink
Improve test coverage (#117)
Browse files Browse the repository at this point in the history
* improve test coverage of check_methods_priority
* replace elif with else to improve branch coverage
  • Loading branch information
fohrloop committed Dec 24, 2023
1 parent 7bd359f commit 1acf15d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions tests/unit/test_core/test_activation/test_prioritization.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ def test_check_methods_priority():

# These should be fine
check_methods_priority(methods_priority=None, methods=methods)
# methods_priority is empty list. Does not crash.
check_methods_priority(methods_priority=[], methods=methods)
# Does not make sense but should not crash.
check_methods_priority(methods_priority=["*"], methods=methods)
# Simple list of methods
check_methods_priority(methods_priority=["A", "B", "F"], methods=methods)
Expand Down Expand Up @@ -45,6 +48,15 @@ def test_check_methods_priority():
):
check_methods_priority(methods_priority=["A", "*", "B", "*"], methods=methods)

# duplicate method names
with pytest.raises(
ValueError,
match=re.escape('Duplicate method name "A" in methods_priority'),
):
check_methods_priority(
methods_priority=["A", "*", "B", {"A", "C"}], methods=methods
)

# Asterisk inside a set
with pytest.raises(
ValueError,
Expand Down
2 changes: 1 addition & 1 deletion wakepy/core/activation.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def get_prioritized_methods_groups(
if item == asterisk:
# Save the location where to add the rest of the methods ('*')
asterisk_index = len(out)
elif isinstance(item, set):
else: # Item is a set but not `asterisk`
out.append({method_dct[name] for name in item})

out_flattened = {m for group in out for m in group}
Expand Down

0 comments on commit 1acf15d

Please sign in to comment.