-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
👌 Improve parsing of need option lists with dynamic functions (#1272)
For need directive options of the format e.g. `:tags: a,[[func()]],b`, this commit consolidates parsing into a single conversion function and adds unit tests
- Loading branch information
1 parent
e5e370e
commit c862e9d
Showing
2 changed files
with
105 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
"""Test utility functions.""" | ||
|
||
import pytest | ||
|
||
from sphinx_needs.api.need import _split_list_with_dyn_funcs | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"input, expected", | ||
[ | ||
(None, []), | ||
([], []), | ||
(["a"], ["a"]), | ||
("a", ["a"]), | ||
("a,b", ["a", "b"]), | ||
("a, b", ["a", "b"]), | ||
("a,b,", ["a", "b"]), | ||
("a|b", ["a", "b"]), | ||
("a| b", ["a", "b"]), | ||
("a|b,", ["a", "b"]), | ||
("a;b", ["a", "b"]), | ||
("a; b", ["a", "b"]), | ||
("a;b,", ["a", "b"]), | ||
("a,b|c;d,", ["a", "b", "c", "d"]), | ||
("[[x,y]],b", ["[[x,y]]", "b"]), | ||
("a,[[x,y]],b", ["a", "[[x,y]]", "b"]), | ||
("a,[[x,y", ["a", "[[x,y]]"]), | ||
("a,[[x,y]", ["a", "[[x,y]]"]), | ||
], | ||
) | ||
def test_split_list_with_dyn_funcs(input, expected): | ||
assert _split_list_with_dyn_funcs(input, None) == expected |