Skip to content

Commit 0a574ea

Browse files
rossbarlarsoner
authored andcommitted
MAINT: Refactor test_xref to use parametrization.
Each pair of input/output in data is treated as an individual test, aiding in detection of specific failures.
1 parent 2d1f690 commit 0a574ea

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

numpydoc/tests/test_xref.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# -*- encoding:utf-8 -*-
2+
import pytest
23
from numpydoc.xref import make_xref
34

45
xref_aliases = {
@@ -114,12 +115,9 @@
114115
xref_ignore = {'or', 'in', 'of', 'default', 'optional'}
115116

116117

117-
def test_make_xref():
118-
for s in data.strip().split('\n\n'):
119-
param_type, expected_result = s.split('\n')
120-
result = make_xref(
121-
param_type,
122-
xref_aliases,
123-
xref_ignore
124-
)
125-
assert result == expected_result
118+
@pytest.mark.parametrize(
119+
('param_type', 'expected_result'),
120+
[tuple(s.split('\n')) for s in data.strip().split('\n\n')]
121+
)
122+
def test_make_xref(param_type, expected_result):
123+
assert make_xref(param_type, xref_aliases, xref_ignore) == expected_result

0 commit comments

Comments
 (0)