From 376650d7501a0d8461ac78b878c093e7323753cd Mon Sep 17 00:00:00 2001 From: Liam DeVoe Date: Sun, 4 Jan 2026 17:33:29 -0500 Subject: [PATCH 1/3] gitignore local claude settings file --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c4557b33a1c..d0e8dc54ba1 100644 --- a/.gitignore +++ b/.gitignore @@ -51,6 +51,7 @@ coverage.xml .vscode __pycache__/ .python-version +.claude/settings.local.json # generated by pip pip-wheel-metadata/ From 57103ef85881b9e397910876731903d83140ad5e Mon Sep 17 00:00:00 2001 From: Liam DeVoe Date: Sun, 4 Jan 2026 17:33:54 -0500 Subject: [PATCH 2/3] clarify pytest_collection_finnish ordering --- changelog/13732.doc.rst | 1 + doc/en/reference/reference.rst | 1 + src/_pytest/hookspec.py | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 changelog/13732.doc.rst diff --git a/changelog/13732.doc.rst b/changelog/13732.doc.rst new file mode 100644 index 00000000000..3f3a0963516 --- /dev/null +++ b/changelog/13732.doc.rst @@ -0,0 +1 @@ +Clarified that the default :hook:`pytest_collection` hook sets ``session.items`` before it calls :hook:`pytest_collection_finish`, not after. diff --git a/doc/en/reference/reference.rst b/doc/en/reference/reference.rst index 8b3ae9fec1b..b4c8feef479 100644 --- a/doc/en/reference/reference.rst +++ b/doc/en/reference/reference.rst @@ -757,6 +757,7 @@ items, delete or otherwise amend the test items: If this hook is implemented in ``conftest.py`` files, it always receives all collected items, not only those under the ``conftest.py`` where it is implemented. +.. hook:: pytest_collection_finish .. autofunction:: pytest_collection_finish Test running (runtest) hooks diff --git a/src/_pytest/hookspec.py b/src/_pytest/hookspec.py index 8c4333810e7..4688c056141 100644 --- a/src/_pytest/hookspec.py +++ b/src/_pytest/hookspec.py @@ -248,8 +248,8 @@ def pytest_collection(session: Session) -> object | None: 1. ``pytest_deselected(items)`` for any deselected items (may be called multiple times) - 3. ``pytest_collection_finish(session)`` - 4. Set ``session.items`` to the list of collected items + 3. Set ``session.items`` to the list of collected items + 4. ``pytest_collection_finish(session)`` 5. Set ``session.testscollected`` to the number of collected items You can implement this hook to only perform some action before collection, From 79ef890a5c8d38e30b1a09e5226ef59a8208e10f Mon Sep 17 00:00:00 2001 From: Liam DeVoe Date: Mon, 5 Jan 2026 01:42:49 -0500 Subject: [PATCH 3/3] correct changelog filename --- changelog/{13732.doc.rst => 14088.doc.rst} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog/{13732.doc.rst => 14088.doc.rst} (100%) diff --git a/changelog/13732.doc.rst b/changelog/14088.doc.rst similarity index 100% rename from changelog/13732.doc.rst rename to changelog/14088.doc.rst