From 99cccde215134337080104c1c80213ec05109f0a Mon Sep 17 00:00:00 2001 From: Thor Whalen <1906276+thorwhalen@users.noreply.github.com> Date: Tue, 11 Aug 2026 00:37:44 +0100 Subject: [PATCH] fix: pytest-9 pytest_ignore_collect signature (CI red since Oct) pytest 9 removed the legacy one-argument pytest_ignore_collect(path) hook form; every CI run failed with a PluginValidationError before collecting a single test. Use the collection_path/config signature (supported since pytest 7, so older environments keep working), with a robust Path-based scrap-dir match instead of the old substring test. Verified locally: pytest --doctest-modules taped -> 7 passed, 1 skipped, taped/scrap excluded from collection. Claude-Session: https://claude.ai/code/session_01GUjT9e7sAyckG1SR9czApr --- conftest.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/conftest.py b/conftest.py index f6bc76e..45bfff1 100644 --- a/conftest.py +++ b/conftest.py @@ -1,8 +1,13 @@ -import os +"""Pytest collection config: keep the scratch package (taped/scrap) out of collection. + +Uses the pytest>=7 ``collection_path``/``config`` hook signature — the legacy +one-argument ``pytest_ignore_collect(path)`` form was removed in pytest 9 and +made every CI run fail with a PluginValidationError before any test ran. +""" import pathlib -def pytest_ignore_collect(path): +def pytest_ignore_collect(collection_path: pathlib.Path, config) -> bool: root_dir = pathlib.Path(__file__).parent.resolve() - scrap_dir = pathlib.PurePath(root_dir, "taped", "scrap") - return str(scrap_dir) in str(path) + scrap_dir = root_dir / "taped" / "scrap" + return scrap_dir == collection_path or scrap_dir in collection_path.parents