54
54
55
55
56
56
def pytest_addoption (parser : Parser ) -> None :
57
- parser .addini (
58
- "norecursedirs" ,
59
- "Directory patterns to avoid for recursion" ,
60
- type = "args" ,
61
- default = [
62
- "*.egg" ,
63
- ".*" ,
64
- "_darcs" ,
65
- "build" ,
66
- "CVS" ,
67
- "dist" ,
68
- "node_modules" ,
69
- "venv" ,
70
- "{arch}" ,
71
- ],
72
- )
73
- parser .addini (
74
- "testpaths" ,
75
- "Directories to search for tests when no files or directories are given on the "
76
- "command line" ,
77
- type = "args" ,
78
- default = [],
79
- )
80
- parser .addini (
81
- "collect_imported_tests" ,
82
- "Whether to collect tests in imported modules outside `testpaths`" ,
83
- type = "bool" ,
84
- default = True ,
85
- )
86
57
group = parser .getgroup ("general" , "Running and selection options" )
87
- group ._addoption (
58
+ group ._addoption ( # private to use reserved lower-case short option
88
59
"-x" ,
89
60
"--exitfirst" ,
90
61
action = "store_const" ,
91
62
dest = "maxfail" ,
92
63
const = 1 ,
93
64
help = "Exit instantly on first error or failed test" ,
94
65
)
95
- group = parser .getgroup ("pytest-warnings" )
96
66
group .addoption (
97
- "-W" ,
98
- "--pythonwarnings" ,
99
- action = "append" ,
100
- help = "Set which warnings to report, see -W option of Python itself" ,
101
- )
102
- parser .addini (
103
- "filterwarnings" ,
104
- type = "linelist" ,
105
- help = "Each line specifies a pattern for "
106
- "warnings.filterwarnings. "
107
- "Processed after -W/--pythonwarnings." ,
108
- )
109
- group ._addoption (
110
67
"--maxfail" ,
111
68
metavar = "num" ,
112
69
action = "store" ,
@@ -115,46 +72,37 @@ def pytest_addoption(parser: Parser) -> None:
115
72
default = 0 ,
116
73
help = "Exit after first num failures or errors" ,
117
74
)
118
- group ._addoption (
75
+ group .addoption (
119
76
"--strict-config" ,
120
77
action = "store_true" ,
121
78
help = "Any warnings encountered while parsing the `pytest` section of the "
122
79
"configuration file raise errors" ,
123
80
)
124
- group ._addoption (
81
+ group .addoption (
125
82
"--strict-markers" ,
126
83
action = "store_true" ,
127
84
help = "Markers not registered in the `markers` section of the configuration "
128
85
"file raise errors" ,
129
86
)
130
- group ._addoption (
87
+ group .addoption (
131
88
"--strict" ,
132
89
action = "store_true" ,
133
90
help = "(Deprecated) alias to --strict-markers" ,
134
91
)
135
- group ._addoption (
136
- "-c" ,
137
- "--config-file" ,
138
- metavar = "FILE" ,
139
- type = str ,
140
- dest = "inifilename" ,
141
- help = "Load configuration from `FILE` instead of trying to locate one of the "
142
- "implicit configuration files." ,
143
- )
144
- group ._addoption (
145
- "--continue-on-collection-errors" ,
146
- action = "store_true" ,
147
- default = False ,
148
- dest = "continue_on_collection_errors" ,
149
- help = "Force test execution even if collection errors occur" ,
92
+
93
+ group = parser .getgroup ("pytest-warnings" )
94
+ group .addoption (
95
+ "-W" ,
96
+ "--pythonwarnings" ,
97
+ action = "append" ,
98
+ help = "Set which warnings to report, see -W option of Python itself" ,
150
99
)
151
- group ._addoption (
152
- "--rootdir" ,
153
- action = "store" ,
154
- dest = "rootdir" ,
155
- help = "Define root directory for tests. Can be relative path: 'root_dir', './root_dir', "
156
- "'root_dir/another_dir/'; absolute path: '/home/user/root_dir'; path with variables: "
157
- "'$HOME/root_dir'." ,
100
+ parser .addini (
101
+ "filterwarnings" ,
102
+ type = "linelist" ,
103
+ help = "Each line specifies a pattern for "
104
+ "warnings.filterwarnings. "
105
+ "Processed after -W/--pythonwarnings." ,
158
106
)
159
107
160
108
group = parser .getgroup ("collect" , "collection" )
@@ -218,6 +166,13 @@ def pytest_addoption(parser: Parser) -> None:
218
166
default = False ,
219
167
help = "Don't ignore tests in a local virtualenv directory" ,
220
168
)
169
+ group .addoption (
170
+ "--continue-on-collection-errors" ,
171
+ action = "store_true" ,
172
+ default = False ,
173
+ dest = "continue_on_collection_errors" ,
174
+ help = "Force test execution even if collection errors occur" ,
175
+ )
221
176
group .addoption (
222
177
"--import-mode" ,
223
178
default = "prepend" ,
@@ -226,6 +181,35 @@ def pytest_addoption(parser: Parser) -> None:
226
181
help = "Prepend/append to sys.path when importing test modules and conftest "
227
182
"files. Default: prepend." ,
228
183
)
184
+ parser .addini (
185
+ "norecursedirs" ,
186
+ "Directory patterns to avoid for recursion" ,
187
+ type = "args" ,
188
+ default = [
189
+ "*.egg" ,
190
+ ".*" ,
191
+ "_darcs" ,
192
+ "build" ,
193
+ "CVS" ,
194
+ "dist" ,
195
+ "node_modules" ,
196
+ "venv" ,
197
+ "{arch}" ,
198
+ ],
199
+ )
200
+ parser .addini (
201
+ "testpaths" ,
202
+ "Directories to search for tests when no files or directories are given on the "
203
+ "command line" ,
204
+ type = "args" ,
205
+ default = [],
206
+ )
207
+ parser .addini (
208
+ "collect_imported_tests" ,
209
+ "Whether to collect tests in imported modules outside `testpaths`" ,
210
+ type = "bool" ,
211
+ default = True ,
212
+ )
229
213
parser .addini (
230
214
"consider_namespace_packages" ,
231
215
type = "bool" ,
@@ -234,6 +218,23 @@ def pytest_addoption(parser: Parser) -> None:
234
218
)
235
219
236
220
group = parser .getgroup ("debugconfig" , "test session debugging and configuration" )
221
+ group ._addoption ( # private to use reserved lower-case short option
222
+ "-c" ,
223
+ "--config-file" ,
224
+ metavar = "FILE" ,
225
+ type = str ,
226
+ dest = "inifilename" ,
227
+ help = "Load configuration from `FILE` instead of trying to locate one of the "
228
+ "implicit configuration files." ,
229
+ )
230
+ group .addoption (
231
+ "--rootdir" ,
232
+ action = "store" ,
233
+ dest = "rootdir" ,
234
+ help = "Define root directory for tests. Can be relative path: 'root_dir', './root_dir', "
235
+ "'root_dir/another_dir/'; absolute path: '/home/user/root_dir'; path with variables: "
236
+ "'$HOME/root_dir'." ,
237
+ )
237
238
group .addoption (
238
239
"--basetemp" ,
239
240
dest = "basetemp" ,
0 commit comments