Skip to content

Commit 61b83cf

Browse files
committed
Add test cases for get_validation_checks().
1 parent 51bcea6 commit 61b83cf

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

numpydoc/tests/test_utils.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
"""Test numpydoc.utils functions."""
2+
3+
import pytest
4+
5+
from numpydoc.validate import ERROR_MSGS
6+
from numpydoc.utils import get_validation_checks
7+
8+
ALL_CHECKS = set(ERROR_MSGS.keys())
9+
10+
11+
@pytest.mark.parametrize(
12+
["checks", "expected"],
13+
[
14+
[{"all"}, ALL_CHECKS],
15+
[set(), set()],
16+
[{"EX01"}, {"EX01"}],
17+
[{"EX01", "SA01"}, {"EX01", "SA01"}],
18+
[{"all", "EX01", "SA01"}, ALL_CHECKS - {"EX01", "SA01"}],
19+
[{"all", "PR01"}, ALL_CHECKS - {"PR01"}],
20+
],
21+
)
22+
def test_utils_get_validation_checks(checks, expected):
23+
"""Ensure check selection is working."""
24+
assert get_validation_checks(checks) == expected
25+
26+
27+
@pytest.mark.parametrize(
28+
"checks",
29+
[
30+
{"every"},
31+
{None},
32+
{"SM10"},
33+
{"EX01", "SM10"},
34+
],
35+
)
36+
def test_get_validation_checks_validity(checks):
37+
"""Ensure that invalid checks are flagged."""
38+
with pytest.raises(ValueError, match="Unrecognized validation code"):
39+
_ = get_validation_checks(checks)

0 commit comments

Comments
 (0)