Skip to content

Python: fix(python): fix tests/samples collection for missing sample imports - #10235

Open
pratik wayase (PratikWayase) wants to merge 1 commit into
microsoft:mainfrom
PratikWayase:fix/9761-samples-collect-error
Open

pratik wayase (PratikWayase) wants to merge 1 commit into
microsoft:mainfrom
PratikWayase:fix/9761-samples-collect-error

Conversation

@PratikWayase

Copy link
Copy Markdown
Contributor

Motivation & Context

python/tests/samples fails to collect on main (#9761): four test modules import samples that no longer exist the three getting_started modules use the tree removed by the 01–05 restructure (#3862, plus Assistants clients removed in #4990), and hosting/test_toolbox_endpoint.py loads samples renamed in #7405. Collection errors abort the whole pytest session, so no test in tests/samples can run.

Description & Review Guide

Major changes

  • Delete the three getting_started test modules (56 parametrized cases, all RUN_SAMPLES_TESTS-gated, never running due to the collection failure).
  • Delete hosting/test_toolbox_endpoint.py; the resolver it tested is covered by packages/foundry_hosting/tests/test_toolbox.py.
  • Port the one uncovered case (multiple trailing slashes on the project endpoint) into test_resolve_endpoint_builds_from_project_and_name as a 3-variant parametrization, matching draft Python: Remove the stale hosted toolbox endpoint sample test #9762 (co-author credit).

Impact

  • uv run pytest tests/samples --collect-only -q: 4 collection errors → 14 tests, 0 errors.
  • uv run pytest packages/foundry_hosting/tests/test_toolbox.py -q: 180 passed.
  • No product code changes.
  • Note: remaining modules carry no openai/azure markers, so the "Test OpenAI/Azure samples" CI steps will collect 0 tests (exit 5) happy to fix those in a follow-up.

Reviewer focus

Coverage map

Removed module Cases Markers Status
getting_started/test_agent_samples.py 46 15 azure, 9 azure_ai, 22 openai imports tree removed by #3862; Assistants cases retired with #4990
getting_started/test_chat_client_samples.py 8 4 azure, 1 azure_ai, 3 openai same
getting_started/test_threads_samples.py 2 2 openai same
hosting/test_toolbox_endpoint.py 5 — samples renamed by #7405; resolver covered by test_toolbox.py, trailing-slash case ported

Related Issue

Fixes #9761

#9762 (draft) covered only the hosting part; per maintainer direction this PR folds it in, with Naveen Chatlapalli (@1aifanatic) credited as co-author. #9762 can be closed in favor of this PR.

AI Assistance

  • This is an AI-assisted contribution. I reviewed, understood, and verified all submitted content and accept responsibility for it.

AI assistance details: draft this description. Verify the fix locally; all changes were reviewed and tested by me.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR links to an agreed issue with no competing open PR, or the Related Issue section documents a trivial-change or repository-automation exception.
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Copilot AI balanced review requested due to automatic review settings November 10, 2026 15:06
@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Nov 10, 2026
@github-actions github-actions Bot changed the title fix(python): fix tests/samples collection for missing sample imports Python: fix(python): fix tests/samples collection for missing sample imports Nov 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The deletions leave CI steps filtering for nonexistent openai/azure-marked sample tests, causing both commands to fail with pytest exit code 5 when RUN_SAMPLES_TESTS=true.

No open issues 🎉

What changed in this PR

Fixes Python sample-test collection failures from #9761 by removing tests that import retired or renamed samples. Preserves the remaining toolbox endpoint edge case in the Foundry hosting package tests, incorporating the scope of #9762.

Changes:

  • Deletes three obsolete getting-started test modules and the stale hosting endpoint test module.
  • Parametrizes the package resolver test for zero, one, and three trailing slashes.
  • Changes tests only; product code is unchanged.
File Description
python/​tests/​samples/​hosting/​test_toolbox_endpoint.py Removes tests loading renamed samples and an obsolete resolver.
python/​tests/​samples/​getting_started/​test_threads_samples.py Removes tests importing retired thread samples.
python/​tests/​samples/​getting_started/​test_chat_client_samples.py Removes tests importing obsolete client samples.
python/​tests/​samples/​getting_started/​test_agent_samples.py Removes tests importing obsolete agent samples.
python/​packages/​foundry_hosting/​tests/​test_toolbox.py Adds trailing-slash variants to endpoint resolution coverage.

Review effort: Balanced

This branch was successfully deployed

1 active deployment
github-app-auth — cf747f10 Deployed Nov 10, 2026 by PratikWayase via team_check #9211
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: tests/samples fails to collect because four test modules import samples that no longer exist

2 participants