Skip to content

Refactor test_pydantic_ai to remove usage of internal functions within tests #5637

Closed as not planned

Description

@ericapisani

Related: https://github.com/getsentry/sentry-python/pull/5629/changes#r2917105295

There's a couple of spots that are using the internal function _set_input_messages that need to be cleaned up.

Ensure that all tests are using public APIs/functions

Activity

  1. linear-code commented on Mar 11, 2026

    @linear-code
  2. Bboyjie commented on Sep 5, 2026

    @Bboyjie

    Hi! I’d like to work on this. I checked the latest master and found that the PydanticAI integration tests still import _set_input_messages directly and call it in 11 places.

    My plan is to replace those direct internal calls with public PydanticAI/Sentry integration paths, using real message types and agent execution where appropriate. I’ll preserve coverage for error handling, disabled prompt capture, system instructions, and binary content, and run the dedicated PydanticAI tox environment plus Ruff.

    I’ll implement this against the current master rather than reuse the previous closed PR. I’m using AI assistance while preparing the patch, but I’ll personally review and test every change before submission. Does this approach sound good?

  3. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Sep 5, 2026
  4. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Sep 15, 2026
  5. DawnofGenX commented on Sep 22, 2026

    @DawnofGenX

    I'd like to take this. I verified the previous attempt (PR #5713) was closed without merging, so no open PR exists. I'll refactor tests/integrations/pydantic_ai/ to use only public APIs and keep the existing coverage green.

  6. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Sep 22, 2026
  7. Morningstar202604 commented on Sep 24, 2026

    @Morningstar202604

    Hi, I went through the pydantic_ai tests and dropped all the direct _set_input_messages calls.

    The five unit tests that called the helper directly (error handling, list content, system prompt part, instructions, prompts disabled) turned out to be already covered by the agent-run tests in the same file, so I deleted them rather than porting the same assertions. The two binary content tests were the only ones that asserted the actual blob payload in the span, so I kept those but rewrote them to go through a real Agent run.

    The pydantic_ai suite passes locally (326 tests), ruff is clean. Happy to adjust if the removal feels too aggressive for any of those cases.

  8. Morningstar202604 commented on Sep 29, 2026

    @Morningstar202604

    Thanks for the context on the earlier attempts. Reading the contribution guidelines properly now — PRs need to wait for a maintainer response on the issue first, which my #7708 didn't do. My mistake.

    The working diff is preserved on that closed PR (drops the direct _set_input_messages calls; the five helper-only unit tests are already covered by the agent-run tests). Happy to hold off on a new PR until someone from the team confirms the approach here — just let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions