René's URL Explorer Experiment


Title: test(pydantic_ai): Remove usage of internal functions from tests by DawnofGenX · Pull Request #7622 · getsentry/sentry-python · GitHub

Open Graph Title: test(pydantic_ai): Remove usage of internal functions from tests by DawnofGenX · Pull Request #7622 · getsentry/sentry-python

X Title: test(pydantic_ai): Remove usage of internal functions from tests by DawnofGenX · Pull Request #7622 · getsentry/sentry-python

Description: Summary Refactors tests/integrations/pydantic_ai/test_pydantic_ai.py so it no longer imports or calls internal (_-prefixed) SDK functions, per CONTRIBUTING ("Don't call private functions") and the review note in #5629. Fixes #5637. What changed (test-only; no sentry_sdk/ changes): Removed imports/calls of _set_input_messages, _set_usage_data, _set_output_data, _set_available_tools, _get_model_name from the test module. Tests that exercised those helpers now drive the public integration surface: ai_client_span() / update_ai_client_span() (with real pydantic_ai message/part objects — UserPromptPart, SystemPromptPart, ModelResponse, RequestUsage — instead of MagicMock messages), and read back the recorded data from the emitted chat span. Several of these tests were previously vacuous (_set_input_messages(span, msgs) + assert transaction is not None — no assertion on captured data). They now assert the actual span attributes (gen_ai.request.messages, gen_ai.system.instructions, gen_ai.request.model, gen_ai.usage.*, gen_ai.request.available_tools, absence of messages when include_prompts=False/PII off), so coverage is strictly increased. Agent-context tests: sentry_init-scoped assertions now use the integration's public helpers get_current_agent()/push_agent()/pop_agent() from sentry_sdk.integrations.pydantic_ai.utils instead of poking scope._contexts["pydantic_ai_agent"]. Note the SDK no longer stores agent state in Scope._contexts at all (it is a private contextvar now), so every one of those _contexts assertions was vacuously true; they now verify the real mechanism. The two tests that injected fake streaming/agent state into scope._contexts were rewritten to exercise ai_client_span() through push_agent()/streaming runs instead of injecting into a private dict. BLOB_DATA_SUBSTITUTE is now asserted as the literal wire value ("[Blob substitute]") with a comment, instead of importing the internal constant from sentry_sdk._types (removes the last from sentry_sdk._types import ... in the file). Renamed two tests whose names referenced internal functions (test_get_model_name_* → test_model_name_*, test_set_usage_data_with_cache_tokens → test_usage_data_with_cache_tokens). Test plan Full integration suite green on both supported pydantic-ai pins after refactor: $ TESTPATH=tests/integrations/pydantic_ai uv run tox -e py3.14-pydantic_ai-latest ====================== 331 passed, 69 warnings in 12.57s ======================= py3.14-pydantic_ai-latest: OK $ TESTPATH=tests/integrations/pydantic_ai uv run tox -e py3.10-pydantic_ai-v1.0.18 ====================== 331 passed, 68 warnings in 35.07s ======================= py3.10-pydantic_ai-v1.0.18: OK No private-underscore usages remain (grep is empty; exit 1 = no match): $ grep -nE "_set_|_should_send_prompts|_get_model_name|_get_context|_get_tool_def|_contexts|from sentry_sdk\._|import _" tests/integrations/pydantic_ai/test_pydantic_ai.py GREP_EXIT=1 Lint: $ uv run ruff check tests All checks passed! $ uv run ruff format tests reformatted (only) Fixes #5637

Open Graph Description: Summary Refactors tests/integrations/pydantic_ai/test_pydantic_ai.py so it no longer imports or calls internal (_-prefixed) SDK functions, per CONTRIBUTING ("Don't call private functions&q...

X Description: Summary Refactors tests/integrations/pydantic_ai/test_pydantic_ai.py so it no longer imports or calls internal (_-prefixed) SDK functions, per CONTRIBUTING ("Don't call private fun...

Opengraph URL: https://github.com/getsentry/sentry-python/pull/7622

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:ea1db893-a05a-cb02-858e-ccf7bc0d7f59
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id88C4:19F84C:963BFE:C30B4E:6B00DE58
html-safe-nonce8898264e03cd8e62dc7242005ffa75a302ac9dc7a2f0970ea88a8c7c74ba6959
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4OEM0OjE5Rjg0Qzo5NjNCRkU6QzMwQjRFOjZCMDBERTU4IiwidmlzaXRvcl9pZCI6IjE1MDMxMTY3ODg3Nzc0MTAxMzYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacb9fc0fdb36c4680a24537e2e453711cd8d199be527070895627128e36fa3d2e3
hovercard-subject-tagpull_request:4606724211
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/getsentry/sentry-python/pull/7622/files
twitter:imagehttps://avatars.githubusercontent.com/u/97001446?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/97001446?s=400&v=4
og:image:altSummary Refactors tests/integrations/pydantic_ai/test_pydantic_ai.py so it no longer imports or calls internal (_-prefixed) SDK functions, per CONTRIBUTING ("Don't call private functions&q...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None043c3f30fbcbe2c6c8e729e10cbbbc90c406546f9fbbb67c648d38f6b7d16daf
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/getsentry/sentry-python git https://github.com/getsentry/sentry-python.git
octolytics-dimension-user_id1396951
octolytics-dimension-user_logingetsentry
octolytics-dimension-repository_id137814779
octolytics-dimension-repository_nwogetsentry/sentry-python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id137814779
octolytics-dimension-repository_network_root_nwogetsentry/sentry-python
turbo-body-classeslogged-out env-production page-responsive
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release5425dc24e8bd8d6fca9641a12afc984825a43875
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/getsentry/sentry-python/pull/7622/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgetsentry%2Fsentry-python%2Fpull%2F7622%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgetsentry%2Fsentry-python%2Fpull%2F7622%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=getsentry%2Fsentry-python
Reloadhttps://github.com/getsentry/sentry-python/pull/7622/files
Reloadhttps://github.com/getsentry/sentry-python/pull/7622/files
Reloadhttps://github.com/getsentry/sentry-python/pull/7622/files
getsentryhttps://github.com/getsentry
sentry-pythonhttps://github.com/getsentry/sentry-python
Codehttps://github.com/getsentry/sentry-python
Issues345 (345)https://github.com/getsentry/sentry-python/issues
Pull requests42 (42)https://github.com/getsentry/sentry-python/pulls
Discussionshttps://github.com/getsentry/sentry-python/discussions
Actionshttps://github.com/getsentry/sentry-python/actions
Security and quality2 (2)https://github.com/getsentry/sentry-python/security
Insightshttps://github.com/getsentry/sentry-python/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fgetsentry%2Fsentry-python%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fgetsentry%2Fsentry-python%2Fissues%2Fnew%2Fchoose
DawnofGenXhttps://github.com/DawnofGenX
getsentry:masterhttps://github.com/getsentry/sentry-python/tree/master
DawnofGenX:fix/issue-5637-pydantic-ai-public-apihttps://github.com/DawnofGenX/sentry-python/tree/fix/issue-5637-pydantic-ai-public-api
Conversation 1 https://github.com/getsentry/sentry-python/pull/7622
Commits 1 https://github.com/getsentry/sentry-python/pull/7622/commits
Checks 4 https://github.com/getsentry/sentry-python/pull/7622/checks
Files changed https://github.com/getsentry/sentry-python/pull/7622/files
Please reload this pagehttps://github.com/getsentry/sentry-python/pull/7622/files
test(pydantic_ai): Remove usage of internal functions from tests https://github.com/getsentry/sentry-python/pull/7622/files#top
Show all changes 1 commit https://github.com/getsentry/sentry-python/pull/7622/files
2dd6330 test(pydantic_ai): Remove usage of internal functions from tests (#5637) DawnofGenX Sep 22, 2026 https://github.com/getsentry/sentry-python/pull/7622/commits/2dd6330b8d7904c7ddd7e7fec01eac603f9c7cac
Clear filters https://github.com/getsentry/sentry-python/pull/7622/files
Please reload this pagehttps://github.com/getsentry/sentry-python/pull/7622/files
Please reload this pagehttps://github.com/getsentry/sentry-python/pull/7622/files
Please reload this pagehttps://github.com/getsentry/sentry-python/pull/7622/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.