Skip to content

Commit c76c3cf

Browse files
committed
test fixture
1 parent 67c2edc commit c76c3cf

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

numpydoc/tests/test_docscrape.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,13 @@
133133
:refguide: random;distributions, random;gauss
134134
135135
'''
136-
doc = NumpyDocString(doc_txt)
136+
137+
@pytest.fixture(params=['',''], ids=["flush", "newline_indented"])
138+
def doc(request):
139+
return NumpyDocString(doc_txt)
140+
141+
142+
doc_firstline = NumpyDocString(doc_txt.lstrip())
137143

138144
doc_yields_txt = """
139145
Test generator
@@ -169,7 +175,7 @@
169175
doc_sent = NumpyDocString(doc_sent_txt)
170176

171177

172-
def test_signature():
178+
def test_signature(doc):
173179
assert doc['Signature'].startswith('numpy.multivariate_normal(')
174180
assert doc['Signature'].endswith('spam=None)')
175181

@@ -183,12 +189,7 @@ def test_extended_summary():
183189
assert doc['Extended Summary'][0].startswith('The multivariate normal')
184190

185191

186-
@pytest.mark.parametrize('sig_on_first_line', (True, False))
187-
def test_parameters(sig_on_first_line):
188-
if sig_on_first_line:
189-
doc = NumpyDocString(doc_txt.lstrip())
190-
else:
191-
doc = NumpyDocString(doc_txt)
192+
def test_parameters(doc):
192193
assert len(doc['Parameters']) == 4
193194
names = [n for n, _, _ in doc['Parameters']]
194195
assert all(a == b for a, b in zip(names, ['mean', 'cov', 'shape']))
@@ -210,15 +211,16 @@ def test_parameters(sig_on_first_line):
210211
assert desc[0].startswith('The type and size')
211212

212213

213-
def test_other_parameters():
214+
def test_other_parameters(doc):
214215
assert len(doc['Other Parameters']) == 1
215216
assert [n for n, _, _ in doc['Other Parameters']] == ['spam']
216217
arg, arg_type, desc = doc['Other Parameters'][0]
217218
assert arg_type == 'parrot'
218219
assert desc[0].startswith('A parrot off its mortal coil')
219220

220221

221-
def test_returns():
222+
223+
def test_returns(doc):
222224
assert len(doc['Returns']) == 3
223225
arg, arg_type, desc = doc['Returns'][0]
224226
assert arg == 'out'

0 commit comments

Comments
 (0)