File tree Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Original file line number Diff line number Diff line change @@ -85,3 +85,55 @@ def test_docs_add_section(tdocstring):
8585 assert 'Notes' in new_docstring
8686 assert '%' not in new_docstring
8787 assert 'new note' in new_docstring
88+
89+ def test_copy_doc_func_to_method (tdocstring ):
90+
91+ def tfunc (): pass
92+ tfunc .__doc__ = tdocstring
93+
94+ class tObj ():
95+
96+ @copy_doc_func_to_method (tfunc )
97+ def tmethod ():
98+ pass
99+
100+ assert tObj .tmethod .__doc__
101+ assert 'first' not in tObj .tmethod .__doc__
102+ assert 'second' in tObj .tmethod .__doc__
103+
104+
105+ def test_copy_doc_class (tdocstring ):
106+
107+ class tObj1 ():
108+ pass
109+ tObj1 .__doc__ = tdocstring
110+
111+ new_section = \
112+ """
113+ third : stuff
114+ Words, words, words.
115+ """
116+ @copy_doc_class (tObj1 , 'Parameters' , new_section )
117+ class tObj2 ():
118+ pass
119+
120+ assert 'third' in tObj2 .__doc__
121+ assert 'third' not in tObj1 .__doc__
122+
123+ def test_replace_docstring_sections (tdocstring ):
124+
125+ # Extract just the parameters section from general test docstring
126+ new_parameters = '\n ' .join (tdocstring .split ('\n ' )[2 :8 ])
127+
128+ @replace_docstring_sections (new_parameters )
129+ def tfunc ():
130+ """Test function docstring
131+
132+ Parameters
133+ ----------
134+ % copied in at runtime
135+ """
136+ pass
137+
138+ assert 'first' in tfunc .__doc__
139+ assert 'second' in tfunc .__doc__
You can’t perform that action at this time.
0 commit comments