@@ -67,6 +67,8 @@ def test_validate_hook(example_module, config, capsys):
67
67
+-------------------------------------------+-------------------------------------+---------+----------------------------------------------------+
68
68
| numpydoc/tests/hooks/example_module.py:28 | example_module.MyClass.process | EX01 | No examples section found |
69
69
+-------------------------------------------+-------------------------------------+---------+----------------------------------------------------+
70
+ | numpydoc/tests/hooks/example_module.py:33 | example_module.NewClass | GL08 | The object does not have a docstring |
71
+ +-------------------------------------------+-------------------------------------+---------+----------------------------------------------------+
70
72
"""
71
73
)
72
74
@@ -102,6 +104,8 @@ def test_validate_hook_with_ignore(example_module, capsys):
102
104
| | | | person (e.g. use "Generate" instead of |
103
105
| | | | "Generates") |
104
106
+-------------------------------------------+-------------------------------------+---------+----------------------------------------------------+
107
+ | numpydoc/tests/hooks/example_module.py:33 | example_module.NewClass | GL08 | The object does not have a docstring |
108
+ +-------------------------------------------+-------------------------------------+---------+----------------------------------------------------+
105
109
"""
106
110
)
107
111
@@ -144,6 +148,8 @@ def test_validate_hook_with_toml_config(example_module, tmp_path, capsys):
144
148
+-------------------------------------------+-------------------------------------+---------+----------------------------------------+
145
149
| numpydoc/tests/hooks/example_module.py:18 | example_module.MyClass.do_something | PR07 | Parameter "*args" has no description |
146
150
+-------------------------------------------+-------------------------------------+---------+----------------------------------------+
151
+ | numpydoc/tests/hooks/example_module.py:33 | example_module.NewClass | GL08 | The object does not have a docstring |
152
+ +-------------------------------------------+-------------------------------------+---------+----------------------------------------+
147
153
"""
148
154
)
149
155
@@ -181,6 +187,8 @@ def test_validate_hook_with_setup_cfg(example_module, tmp_path, capsys):
181
187
+-------------------------------------------+-------------------------------------+---------+----------------------------------------+
182
188
| numpydoc/tests/hooks/example_module.py:18 | example_module.MyClass.do_something | PR07 | Parameter "*args" has no description |
183
189
+-------------------------------------------+-------------------------------------+---------+----------------------------------------+
190
+ | numpydoc/tests/hooks/example_module.py:33 | example_module.NewClass | GL08 | The object does not have a docstring |
191
+ +-------------------------------------------+-------------------------------------+---------+----------------------------------------+
184
192
"""
185
193
)
186
194
@@ -199,3 +207,84 @@ def test_validate_hook_help(capsys):
199
207
out = capsys .readouterr ().out
200
208
assert "--ignore" in out
201
209
assert "--config" in out
210
+
211
+
212
+ def test_validate_hook_exclude_option_pyproject (example_module , tmp_path , capsys ):
213
+ """
214
+ Test that a file is correctly processed with the config coming from
215
+ a pyproject.toml file and exclusions provided.
216
+ """
217
+
218
+ with open (tmp_path / "pyproject.toml" , "w" ) as config_file :
219
+ config_file .write (
220
+ inspect .cleandoc (
221
+ r"""
222
+ [tool.numpydoc_validation]
223
+ checks = [
224
+ "all",
225
+ "EX01",
226
+ "SA01",
227
+ "ES01",
228
+ ]
229
+ override_SS05 = '^((Process|Assess|Access) )'
230
+ exclude = [
231
+ '\.do_something$',
232
+ '\.__init__$',
233
+ ]
234
+ """
235
+ )
236
+ )
237
+
238
+ expected = inspect .cleandoc (
239
+ """
240
+ +-------------------------------------------+------------------------------+---------+--------------------------------------+
241
+ | file | item | check | description |
242
+ +===========================================+==============================+=========+======================================+
243
+ | numpydoc/tests/hooks/example_module.py:4 | example_module.some_function | PR01 | Parameters {'name'} not documented |
244
+ +-------------------------------------------+------------------------------+---------+--------------------------------------+
245
+ | numpydoc/tests/hooks/example_module.py:33 | example_module.NewClass | GL08 | The object does not have a docstring |
246
+ +-------------------------------------------+------------------------------+---------+--------------------------------------+
247
+ """
248
+ )
249
+
250
+ return_code = main ([example_module , "--config" , str (tmp_path )])
251
+ assert return_code == 1
252
+ assert capsys .readouterr ().err .rstrip () == expected
253
+
254
+
255
+ def test_validate_hook_exclude_option_setup_cfg (example_module , tmp_path , capsys ):
256
+ """
257
+ Test that a file is correctly processed with the config coming from
258
+ a setup.cfg file and exclusions provided.
259
+ """
260
+
261
+ with open (tmp_path / "setup.cfg" , "w" ) as config_file :
262
+ config_file .write (
263
+ inspect .cleandoc (
264
+ """
265
+ [tool:numpydoc_validation]
266
+ checks = all,EX01,SA01,ES01
267
+ override_SS05 = ^((Process|Assess|Access) )
268
+ override_GL08 = ^(__init__)$
269
+ exclude = \\ .NewClass$,
270
+ """
271
+ )
272
+ )
273
+
274
+ expected = inspect .cleandoc (
275
+ """
276
+ +-------------------------------------------+-------------------------------------+---------+----------------------------------------+
277
+ | file | item | check | description |
278
+ +===========================================+=====================================+=========+========================================+
279
+ | numpydoc/tests/hooks/example_module.py:4 | example_module.some_function | PR01 | Parameters {'name'} not documented |
280
+ +-------------------------------------------+-------------------------------------+---------+----------------------------------------+
281
+ | numpydoc/tests/hooks/example_module.py:18 | example_module.MyClass.do_something | PR01 | Parameters {'**kwargs'} not documented |
282
+ +-------------------------------------------+-------------------------------------+---------+----------------------------------------+
283
+ | numpydoc/tests/hooks/example_module.py:18 | example_module.MyClass.do_something | PR07 | Parameter "*args" has no description |
284
+ +-------------------------------------------+-------------------------------------+---------+----------------------------------------+
285
+ """
286
+ )
287
+
288
+ return_code = main ([example_module , "--config" , str (tmp_path )])
289
+ assert return_code == 1
290
+ assert capsys .readouterr ().err .rstrip () == expected
0 commit comments