1212@hookspec (historic = True )
1313def pytest_addhooks (pluginmanager ):
1414 """called at plugin registration time to allow adding new hooks via a call to
15- pluginmanager.add_hookspecs(module_or_class, prefix)."""
15+ ``pluginmanager.add_hookspecs(module_or_class, prefix)``.
16+
17+
18+ :param _pytest.config.PytestPluginManager pluginmanager: pytest plugin manager
19+ """
1620
1721
1822@hookspec (historic = True )
1923def pytest_namespace ():
2024 """
21- DEPRECATED: this hook causes direct monkeypatching on pytest, its use is strongly discouraged
25+ (**Deprecated**) this hook causes direct monkeypatching on pytest, its use is strongly discouraged
2226 return dict of name->object to be made globally available in
23- the pytest namespace. This hook is called at plugin registration
24- time.
27+ the pytest namespace.
28+
29+ This hook is called at plugin registration time.
2530 """
2631
2732
2833@hookspec (historic = True )
2934def pytest_plugin_registered (plugin , manager ):
30- """ a new pytest plugin got registered. """
35+ """ a new pytest plugin got registered.
36+
37+ :param plugin: the plugin module or instance
38+ :param _pytest.config.PytestPluginManager manager: pytest plugin manager
39+ """
3140
3241
3342@hookspec (historic = True )
@@ -41,7 +50,7 @@ def pytest_addoption(parser):
4150 files situated at the tests root directory due to how pytest
4251 :ref:`discovers plugins during startup <pluginorder>`.
4352
44- :arg parser: To add command line options, call
53+ :arg _pytest.config.Parser parser: To add command line options, call
4554 :py:func:`parser.addoption(...) <_pytest.config.Parser.addoption>`.
4655 To add ini-file values call :py:func:`parser.addini(...)
4756 <_pytest.config.Parser.addini>`.
@@ -56,8 +65,7 @@ def pytest_addoption(parser):
5665 a value read from an ini-style file.
5766
5867 The config object is passed around on many internal objects via the ``.config``
59- attribute or can be retrieved as the ``pytestconfig`` fixture or accessed
60- via (deprecated) ``pytest.config``.
68+ attribute or can be retrieved as the ``pytestconfig`` fixture.
6169 """
6270
6371
@@ -72,8 +80,7 @@ def pytest_configure(config):
7280 After that, the hook is called for other conftest files as they are
7381 imported.
7482
75- :arg config: pytest config object
76- :type config: _pytest.config.Config
83+ :arg _pytest.config.Config config: pytest config object
7784 """
7885
7986# -------------------------------------------------------------------------
@@ -87,24 +94,43 @@ def pytest_configure(config):
8794def pytest_cmdline_parse (pluginmanager , args ):
8895 """return initialized config object, parsing the specified args.
8996
90- Stops at first non-None result, see :ref:`firstresult` """
97+ Stops at first non-None result, see :ref:`firstresult`
98+
99+ :param _pytest.config.PytestPluginManager pluginmanager: pytest plugin manager
100+ :param list[str] args: list of arguments passed on the command line
101+ """
91102
92103
93104def pytest_cmdline_preparse (config , args ):
94- """(deprecated) modify command line arguments before option parsing. """
105+ """(**Deprecated**) modify command line arguments before option parsing.
106+
107+ This hook is considered deprecated and will be removed in a future pytest version. Consider
108+ using :func:`pytest_load_initial_conftests` instead.
109+
110+ :param _pytest.config.Config config: pytest config object
111+ :param list[str] args: list of arguments passed on the command line
112+ """
95113
96114
97115@hookspec (firstresult = True )
98116def pytest_cmdline_main (config ):
99117 """ called for performing the main command line action. The default
100118 implementation will invoke the configure hooks and runtest_mainloop.
101119
102- Stops at first non-None result, see :ref:`firstresult` """
120+ Stops at first non-None result, see :ref:`firstresult`
121+
122+ :param _pytest.config.Config config: pytest config object
123+ """
103124
104125
105126def pytest_load_initial_conftests (early_config , parser , args ):
106127 """ implements the loading of initial conftest files ahead
107- of command line option parsing. """
128+ of command line option parsing.
129+
130+ :param _pytest.config.Config early_config: pytest config object
131+ :param list[str] args: list of arguments passed on the command line
132+ :param _pytest.config.Parser parser: to add command line options
133+ """
108134
109135
110136# -------------------------------------------------------------------------
@@ -113,18 +139,29 @@ def pytest_load_initial_conftests(early_config, parser, args):
113139
114140@hookspec (firstresult = True )
115141def pytest_collection (session ):
116- """ perform the collection protocol for the given session.
142+ """Perform the collection protocol for the given session.
117143
118- Stops at first non-None result, see :ref:`firstresult` """
144+ Stops at first non-None result, see :ref:`firstresult`.
145+
146+ :param _pytest.main.Session session: the pytest session object
147+ """
119148
120149
121150def pytest_collection_modifyitems (session , config , items ):
122151 """ called after collection has been performed, may filter or re-order
123- the items in-place."""
152+ the items in-place.
153+
154+ :param _pytest.main.Session session: the pytest session object
155+ :param _pytest.config.Config config: pytest config object
156+ :param List[_pytest.main.Item] items: list of item objects
157+ """
124158
125159
126160def pytest_collection_finish (session ):
127- """ called after collection has been performed and modified. """
161+ """ called after collection has been performed and modified.
162+
163+ :param _pytest.main.Session session: the pytest session object
164+ """
128165
129166
130167@hookspec (firstresult = True )
@@ -134,19 +171,28 @@ def pytest_ignore_collect(path, config):
134171 more specific hooks.
135172
136173 Stops at first non-None result, see :ref:`firstresult`
174+
175+ :param str path: the path to analyze
176+ :param _pytest.config.Config config: pytest config object
137177 """
138178
139179
140180@hookspec (firstresult = True )
141181def pytest_collect_directory (path , parent ):
142182 """ called before traversing a directory for collection files.
143183
144- Stops at first non-None result, see :ref:`firstresult` """
184+ Stops at first non-None result, see :ref:`firstresult`
185+
186+ :param str path: the path to analyze
187+ """
145188
146189
147190def pytest_collect_file (path , parent ):
148191 """ return collection Node or None for the given path. Any new node
149- needs to have the specified ``parent`` as a parent."""
192+ needs to have the specified ``parent`` as a parent.
193+
194+ :param str path: the path to collect
195+ """
150196
151197# logging hooks for collection
152198
@@ -212,7 +258,12 @@ def pytest_make_parametrize_id(config, val, argname):
212258 by @pytest.mark.parametrize calls. Return None if the hook doesn't know about ``val``.
213259 The parameter name is available as ``argname``, if required.
214260
215- Stops at first non-None result, see :ref:`firstresult` """
261+ Stops at first non-None result, see :ref:`firstresult`
262+
263+ :param _pytest.config.Config config: pytest config object
264+ :param val: the parametrized value
265+ :param str argname: the automatic parameter name produced by pytest
266+ """
216267
217268# -------------------------------------------------------------------------
218269# generic runtest related hooks
@@ -224,11 +275,14 @@ def pytest_runtestloop(session):
224275 """ called for performing the main runtest loop
225276 (after collection finished).
226277
227- Stops at first non-None result, see :ref:`firstresult` """
278+ Stops at first non-None result, see :ref:`firstresult`
279+
280+ :param _pytest.main.Session session: the pytest session object
281+ """
228282
229283
230284def pytest_itemstart (item , node ):
231- """ (deprecated, use pytest_runtest_logstart) . """
285+ """(**Deprecated**) use pytest_runtest_logstart. """
232286
233287
234288@hookspec (firstresult = True )
@@ -307,15 +361,25 @@ def pytest_fixture_post_finalizer(fixturedef, request):
307361
308362
309363def pytest_sessionstart (session ):
310- """ before session.main() is called. """
364+ """ before session.main() is called.
365+
366+ :param _pytest.main.Session session: the pytest session object
367+ """
311368
312369
313370def pytest_sessionfinish (session , exitstatus ):
314- """ whole test run finishes. """
371+ """ whole test run finishes.
372+
373+ :param _pytest.main.Session session: the pytest session object
374+ :param int exitstatus: the status which pytest will return to the system
375+ """
315376
316377
317378def pytest_unconfigure (config ):
318- """ called before test process is exited. """
379+ """ called before test process is exited.
380+
381+ :param _pytest.config.Config config: pytest config object
382+ """
319383
320384
321385# -------------------------------------------------------------------------
@@ -329,6 +393,8 @@ def pytest_assertrepr_compare(config, op, left, right):
329393 of strings. The strings will be joined by newlines but any newlines
330394 *in* a string will be escaped. Note that all but the first line will
331395 be indented slightly, the intention is for the first line to be a summary.
396+
397+ :param _pytest.config.Config config: pytest config object
332398 """
333399
334400# -------------------------------------------------------------------------
@@ -339,7 +405,7 @@ def pytest_assertrepr_compare(config, op, left, right):
339405def pytest_report_header (config , startdir ):
340406 """ return a string or list of strings to be displayed as header info for terminal reporting.
341407
342- :param config: the pytest config object.
408+ :param _pytest. config.Config config: pytest config object
343409 :param startdir: py.path object with the starting dir
344410
345411 .. note::
@@ -358,7 +424,7 @@ def pytest_report_collectionfinish(config, startdir, items):
358424
359425 This strings will be displayed after the standard "collected X items" message.
360426
361- :param config: the pytest config object.
427+ :param _pytest. config.Config config: pytest config object
362428 :param startdir: py.path object with the starting dir
363429 :param items: list of pytest items that are going to be executed; this list should not be modified.
364430 """
@@ -418,6 +484,5 @@ def pytest_enter_pdb(config):
418484 """ called upon pdb.set_trace(), can be used by plugins to take special
419485 action just before the python debugger enters in interactive mode.
420486
421- :arg config: pytest config object
422- :type config: _pytest.config.Config
487+ :param _pytest.config.Config config: pytest config object
423488 """
0 commit comments