Skip to content

Fix param parsing. #286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 10, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test fixture
  • Loading branch information
Carreau committed Jul 24, 2020
commit c76c3cf2cc2f7d57dbce484ba73c1d66bbce6eba
22 changes: 12 additions & 10 deletions numpydoc/tests/test_docscrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,13 @@
:refguide: random;distributions, random;gauss

'''
doc = NumpyDocString(doc_txt)

@pytest.fixture(params=['',''], ids=["flush", "newline_indented"])
def doc(request):
return NumpyDocString(doc_txt)


doc_firstline = NumpyDocString(doc_txt.lstrip())

doc_yields_txt = """
Test generator
Expand Down Expand Up @@ -169,7 +175,7 @@
doc_sent = NumpyDocString(doc_sent_txt)


def test_signature():
def test_signature(doc):
assert doc['Signature'].startswith('numpy.multivariate_normal(')
assert doc['Signature'].endswith('spam=None)')

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


@pytest.mark.parametrize('sig_on_first_line', (True, False))
def test_parameters(sig_on_first_line):
if sig_on_first_line:
doc = NumpyDocString(doc_txt.lstrip())
else:
doc = NumpyDocString(doc_txt)
def test_parameters(doc):
assert len(doc['Parameters']) == 4
names = [n for n, _, _ in doc['Parameters']]
assert all(a == b for a, b in zip(names, ['mean', 'cov', 'shape']))
Expand All @@ -210,15 +211,16 @@ def test_parameters(sig_on_first_line):
assert desc[0].startswith('The type and size')


def test_other_parameters():
def test_other_parameters(doc):
assert len(doc['Other Parameters']) == 1
assert [n for n, _, _ in doc['Other Parameters']] == ['spam']
arg, arg_type, desc = doc['Other Parameters'][0]
assert arg_type == 'parrot'
assert desc[0].startswith('A parrot off its mortal coil')


def test_returns():

def test_returns(doc):
assert len(doc['Returns']) == 3
arg, arg_type, desc = doc['Returns'][0]
assert arg == 'out'
Expand Down