Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

test(ci): exempt pytest's own collection rule from the test-path guard (#1657)

Raghav Chamadiyaac6c14b7bce3
diff --git a/packages/core/src/repowise/core/ingestion/framework_edges/pytest_edges.py b/packages/core/src/repowise/core/ingestion/framework_edges/pytest_edges.py
index 056f0ba64..44d3c225b 100644
--- a/packages/core/src/repowise/core/ingestion/framework_edges/pytest_edges.py
+++ b/packages/core/src/repowise/core/ingestion/framework_edges/pytest_edges.py
@@ -35,6 +35,17 @@ _QUOTED_RE = re.compile(r"""["']([^"']*)["']""")
# fixture's name.
_NAME_KWARG_ARG_RE = re.compile(r"""^name\s*=\s*["']([^"']+)["']$""")
+# pytest's own `python_files` default, and deliberately not the shared
+# `is_test_path`. A fixture is injected only into a file pytest actually
+# collects, so this has to answer "does pytest run this?" — a narrower question
+# than "is this test-related code", which also claims `conftest.py`, a
+# `tests/helpers.py` and every non-Python spec layout. Widening it would inject
+# fixture parameters into files that are never collected.
+#
+# Ceiling: `python_files` is configurable and this assumes the default, unlike
+# `_DEFAULT_TEST_CLASS_GLOBS` below, which reads the setting because assuming it
+# cost 346 of celery's 359 bindings. No corpus repo overrides `python_files`, so
+# the same mistake is not yet demonstrable here.
_TEST_FILE_RE = re.compile(r"(?:^|/)(?:test_[^/]*|[^/]*_test)\.py$")
# pytest collects methods only from classes matching `python_classes`, so a
diff --git a/tests/unit/test_no_test_path_copies.py b/tests/unit/test_no_test_path_copies.py
index 37c3395c4..966362e0d 100644
--- a/tests/unit/test_no_test_path_copies.py
+++ b/tests/unit/test_no_test_path_copies.py
@@ -88,6 +88,12 @@ _KNOWN: frozenset[str] = frozenset(
# handler under an OpenAPI `spec/` is a real service contract, and
# over-excluding drops it from the workspace contract map entirely.
"packages/core/src/repowise/core/workspace/extractors/base.py",
+ # pytest's own `python_files` rule, not ours: a fixture is injected
+ # only into a file pytest collects, so this asks "does pytest run
+ # this?" rather than "is this test-related code". The shared rules also
+ # claim `conftest.py` and `tests/helpers.py`, and giving those fixture
+ # parameters would be wrong.
+ "packages/core/src/repowise/core/ingestion/framework_edges/pytest_edges.py",
}
)