diff --git a/changelog/14557.doc.rst b/changelog/14557.doc.rst new file mode 100644 index 00000000000..38d10046375 --- /dev/null +++ b/changelog/14557.doc.rst @@ -0,0 +1 @@ +Clarified that conftest files discovered during collection are not available for hooks which run before collection, such as :hook:`pytest_sessionstart` and :hook:`pytest_report_header`. diff --git a/doc/en/how-to/writing_plugins.rst b/doc/en/how-to/writing_plugins.rst index 56043a14f97..386eb8f5f65 100644 --- a/doc/en/how-to/writing_plugins.rst +++ b/doc/en/how-to/writing_plugins.rst @@ -59,6 +59,11 @@ Plugin discovery order at tool startup After a ``conftest.py`` file is loaded, recursively load all plugins specified in its :globalvar:`pytest_plugins` variable if present. + These initial conftest files are loaded before collection starts. Conftest + files discovered later during collection can still implement hooks, but they + are not available for hooks which run before collection, such as + :hook:`pytest_sessionstart` and :hook:`pytest_report_header`. + .. _`conftest.py plugins`: .. _`localplugin`: