mirror of
https://github.com/pydantic/pydantic-ai-harness.git
synced 2026-07-21 02:45:34 +00:00
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:
co-authored by
Claude Opus 4.8
parent
f460861435
commit
4e21f7bcbf
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user