5454
5555
5656def 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- )
8657 group = parser .getgroup ("general" , "Running and selection options" )
87- group ._addoption (
58+ group ._addoption ( # private to use reserved lower-case short option
8859 "-x" ,
8960 "--exitfirst" ,
9061 action = "store_const" ,
9162 dest = "maxfail" ,
9263 const = 1 ,
9364 help = "Exit instantly on first error or failed test" ,
9465 )
95- group = parser .getgroup ("pytest-warnings" )
9666 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 (
11067 "--maxfail" ,
11168 metavar = "num" ,
11269 action = "store" ,
@@ -115,46 +72,37 @@ def pytest_addoption(parser: Parser) -> None:
11572 default = 0 ,
11673 help = "Exit after first num failures or errors" ,
11774 )
118- group ._addoption (
75+ group .addoption (
11976 "--strict-config" ,
12077 action = "store_true" ,
12178 help = "Any warnings encountered while parsing the `pytest` section of the "
12279 "configuration file raise errors" ,
12380 )
124- group ._addoption (
81+ group .addoption (
12582 "--strict-markers" ,
12683 action = "store_true" ,
12784 help = "Markers not registered in the `markers` section of the configuration "
12885 "file raise errors" ,
12986 )
130- group ._addoption (
87+ group .addoption (
13188 "--strict" ,
13289 action = "store_true" ,
13390 help = "(Deprecated) alias to --strict-markers" ,
13491 )
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" ,
15099 )
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." ,
158106 )
159107
160108 group = parser .getgroup ("collect" , "collection" )
@@ -218,6 +166,13 @@ def pytest_addoption(parser: Parser) -> None:
218166 default = False ,
219167 help = "Don't ignore tests in a local virtualenv directory" ,
220168 )
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+ )
221176 group .addoption (
222177 "--import-mode" ,
223178 default = "prepend" ,
@@ -226,6 +181,35 @@ def pytest_addoption(parser: Parser) -> None:
226181 help = "Prepend/append to sys.path when importing test modules and conftest "
227182 "files. Default: prepend." ,
228183 )
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+ )
229213 parser .addini (
230214 "consider_namespace_packages" ,
231215 type = "bool" ,
@@ -234,6 +218,23 @@ def pytest_addoption(parser: Parser) -> None:
234218 )
235219
236220 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+ )
237238 group .addoption (
238239 "--basetemp" ,
239240 dest = "basetemp" ,
0 commit comments