1
1
"""Test the numpydoc validate pre-commit hook."""
2
2
3
3
import inspect
4
+ import os
4
5
from pathlib import Path
5
6
6
7
import pytest
@@ -40,8 +41,6 @@ def test_validate_hook(example_module, config, capsys):
40
41
41
42
numpydoc/tests/hooks/example_module.py:8: EX01 No examples section found
42
43
43
- numpydoc/tests/hooks/example_module.py:11: GL08 The object does not have a docstring
44
-
45
44
numpydoc/tests/hooks/example_module.py:17: ES01 No extended summary found
46
45
47
46
numpydoc/tests/hooks/example_module.py:17: PR01 Parameters {'**kwargs'} not documented
@@ -61,8 +60,24 @@ def test_validate_hook(example_module, config, capsys):
61
60
numpydoc/tests/hooks/example_module.py:26: EX01 No examples section found
62
61
63
62
numpydoc/tests/hooks/example_module.py:30: GL08 The object does not have a docstring
63
+
64
+ numpydoc/tests/hooks/example_module.py:31: SA01 See Also section not found
65
+
66
+ numpydoc/tests/hooks/example_module.py:31: EX01 No examples section found
67
+
68
+ numpydoc/tests/hooks/example_module.py:46: SA01 See Also section not found
69
+
70
+ numpydoc/tests/hooks/example_module.py:46: EX01 No examples section found
71
+
72
+ numpydoc/tests/hooks/example_module.py:58: ES01 No extended summary found
73
+
74
+ numpydoc/tests/hooks/example_module.py:58: PR01 Parameters {'name'} not documented
75
+
76
+ numpydoc/tests/hooks/example_module.py:58: SA01 See Also section not found
77
+
78
+ numpydoc/tests/hooks/example_module.py:58: EX01 No examples section found
64
79
"""
65
- )
80
+ ). replace ( "/" , os . sep )
66
81
67
82
return_code = run_hook ([example_module ], config = config )
68
83
assert return_code == 1
@@ -79,17 +94,17 @@ def test_validate_hook_with_ignore(example_module, capsys):
79
94
"""
80
95
numpydoc/tests/hooks/example_module.py:4: PR01 Parameters {'name'} not documented
81
96
82
- numpydoc/tests/hooks/example_module.py:11: GL08 The object does not have a docstring
83
-
84
97
numpydoc/tests/hooks/example_module.py:17: PR01 Parameters {'**kwargs'} not documented
85
98
86
99
numpydoc/tests/hooks/example_module.py:17: PR07 Parameter "*args" has no description
87
100
88
101
numpydoc/tests/hooks/example_module.py:26: SS05 Summary must start with infinitive verb, not third person (e.g. use "Generate" instead of "Generates")
89
102
90
103
numpydoc/tests/hooks/example_module.py:30: GL08 The object does not have a docstring
104
+
105
+ numpydoc/tests/hooks/example_module.py:58: PR01 Parameters {'name'} not documented
91
106
"""
92
- )
107
+ ). replace ( "/" , os . sep )
93
108
94
109
return_code = run_hook ([example_module ], ignore = ["ES01" , "SA01" , "EX01" ])
95
110
@@ -132,7 +147,7 @@ def test_validate_hook_with_toml_config(example_module, tmp_path, capsys):
132
147
133
148
numpydoc/tests/hooks/example_module.py:30: GL08 The object does not have a docstring
134
149
"""
135
- )
150
+ ). replace ( "/" , os . sep )
136
151
137
152
return_code = run_hook ([example_module ], config = tmp_path )
138
153
assert return_code == 1
@@ -167,7 +182,7 @@ def test_validate_hook_with_setup_cfg(example_module, tmp_path, capsys):
167
182
168
183
numpydoc/tests/hooks/example_module.py:30: GL08 The object does not have a docstring
169
184
"""
170
- )
185
+ ). replace ( "/" , os . sep )
171
186
172
187
return_code = run_hook ([example_module ], config = tmp_path )
173
188
assert return_code == 1
@@ -208,7 +223,7 @@ def test_validate_hook_exclude_option_pyproject(example_module, tmp_path, capsys
208
223
209
224
numpydoc/tests/hooks/example_module.py:30: GL08 The object does not have a docstring
210
225
"""
211
- )
226
+ ). replace ( "/" , os . sep )
212
227
213
228
return_code = run_hook ([example_module ], config = tmp_path )
214
229
assert return_code == 1
@@ -241,8 +256,11 @@ def test_validate_hook_exclude_option_setup_cfg(example_module, tmp_path, capsys
241
256
242
257
numpydoc/tests/hooks/example_module.py:17: PR07 Parameter "*args" has no description
243
258
"""
244
- )
259
+ ). replace ( "/" , os . sep )
245
260
246
261
return_code = run_hook ([example_module ], config = tmp_path )
247
262
assert return_code == 1
248
263
assert capsys .readouterr ().err .strip () == expected
264
+
265
+
266
+ # def test_validate_hook_
0 commit comments