Skip to content

Commit 101cc55

Browse files
committed
update test procedure for docstring related functions
1 parent dcb5d6f commit 101cc55

File tree

3 files changed

+30
-35
lines changed

3 files changed

+30
-35
lines changed

fooof/tests/conftest.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from fooof.core.modutils import safe_import
1010

11-
from fooof.tests.tutils import get_tfm, get_tfg, get_tbands, get_tresults
11+
from fooof.tests.tutils import get_tfm, get_tfg, get_tbands, get_tresults, get_tdocstring
1212
from fooof.tests.settings import (BASE_TEST_FILE_PATH, TEST_DATA_PATH,
1313
TEST_REPORTS_PATH, TEST_PLOTS_PATH)
1414

@@ -52,6 +52,10 @@ def tbands():
5252
def tresults():
5353
yield get_tresults()
5454

55+
@pytest.fixture(scope='function')
56+
def tdocstring():
57+
yield get_tdocstring()
58+
5559
@pytest.fixture(scope='session')
5660
def skip_if_no_mpl():
5761
if not safe_import('matplotlib'):

fooof/tests/core/test_modutils.py

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -33,43 +33,13 @@ def subfunc_bad():
3333
with raises(ImportError):
3434
subfunc_bad()
3535

36-
def test_docs_drop_param():
36+
def test_docs_drop_param(tdocstring):
3737

38-
ds = """STUFF
39-
40-
Parameters
41-
----------
42-
first : thing
43-
Words, words, words.
44-
second : stuff
45-
Words, words, words.
46-
47-
Returns
48-
-------
49-
out : yay
50-
Words, words, words.
51-
"""
52-
53-
out = docs_drop_param(ds)
38+
out = docs_drop_param(tdocstring)
5439
assert 'first' not in out
5540
assert 'second' in out
5641

57-
def test_docs_append_to_section():
58-
59-
ds = """STUFF
60-
61-
Parameters
62-
----------
63-
first : thing
64-
Words, words, words.
65-
second : stuff
66-
Words, words, words.
67-
68-
Returns
69-
-------
70-
out : yay
71-
Words, words, words.
72-
"""
42+
def test_docs_append_to_section(tdocstring):
7343

7444
section = 'Parameters'
7545
add = \
@@ -78,7 +48,7 @@ def test_docs_append_to_section():
7848
Added description.
7949
"""
8050

81-
new_ds = docs_append_to_section(ds, section, add)
51+
new_ds = docs_append_to_section(tdocstring, section, add)
8252

8353
assert 'third' in new_ds
8454
assert 'Added description' in new_ds

fooof/tests/tutils.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,27 @@ def get_tresults():
5454
r_squared=0.97, error=0.01,
5555
gaussian_params=np.array([[10.0, 1.25, 1.0], [20.0, 1.0, 1.5]]))
5656

57+
def get_tdocstring():
58+
"""Get an example docstring, for testing."""
59+
60+
docstring = \
61+
"""This is a test doctring.
62+
63+
Parameters
64+
----------
65+
first : thing
66+
Words, words, words.
67+
second : stuff
68+
Words, words, words.
69+
70+
Returns
71+
-------
72+
out : yay
73+
Words, words, words.
74+
"""
75+
76+
return docstring
77+
5778
def default_group_params():
5879
"""Create default parameters for generating a test group of power spectra."""
5980

0 commit comments

Comments
 (0)