docs(agents): discourage private-helper imports in tests (#316)

Keep tests pinned to each capability's public surface so they keep
passing across internal refactors of the `_`-prefixed modules, and
point genuinely unreachable branches at `# pragma: no cover` instead
of reaching into private helpers.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Aditya Vardhan
2026-06-30 17:08:21 +05:30
committed by GitHub
co-authored by Claude Opus 4.8
parent f460861435
commit 4e21f7bcbf
+8
View File
@@ -138,6 +138,14 @@ need.
- Prefer tests through `Agent(..., capabilities=[...])` when that is the public
behavior. Use direct `Toolset`/`RunContext` tests for lower-level lifecycle,
schema, retry, or wrapper behavior that is hard to isolate through `Agent`.
- Don't import private (`_`-prefixed) helpers into tests. Exercise them through
the capability's public surface so tests survive internal refactors: drive the
behavior through `Agent(..., capabilities=[...])`, or import the public class
re-exported from the capability package's `__init__.py` (e.g.
`from pydantic_ai_harness.filesystem import FileSystemToolset`, not
`from pydantic_ai_harness.filesystem._toolset import _content_hash`). When a
branch is only reachable by calling a private helper directly, mark it
`# pragma: no cover` rather than reaching into the helper from a test.
## Contributing rules for AICAs