[python] Add mock API tests for service/multiple-services and fix generator duplicate class name bug#10358
Draft
[python] Add mock API tests for service/multiple-services and fix generator duplicate class name bug#10358
service/multiple-services and fix generator duplicate class name bug#10358Conversation
…on generator duplicate class name bug Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/f6707ceb-9032-4e54-a7f1-848683922d4e Co-authored-by: msyyc <[email protected]>
Copilot
AI
changed the title
[WIP] Add test case for pull request 4221
[python] Add mock API tests for Apr 13, 2026
service/multiple-services and fix generator duplicate class name bug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds Python SDK mock API tests for the
service/multiple-servicesSpector scenario. The spec was previously inSKIP_SPECSdue to a Python generator bug where multiple clients sharing operation group names in the same namespace would produce duplicate class definitions — causing the second to silently overwrite the first.Generator fix: merge duplicate operation group classes
When two clients (e.g.
ServiceAClient,ServiceBClient) both have anOperationsinterface in the same namespace, the generator now merges them into a single class with all operations, rather than emitting two identically-named classes.Before (broken):
_operations.pycontained twoclass Operations:definitions; ServiceA's was overwritten by ServiceB's, soServiceAClient.operations.op_a()raisedAttributeError.After:
Each client instantiates
Operationswith its own config (ServiceAClientConfiguration/ServiceBClientConfiguration), so routing and API version remain correct per client.Changed files:
generator/pygen/codegen/serializers/__init__.py— deduplicate operation groups by class name before serialization; merge operations from duplicates into the first groupgenerator/pygen/codegen/serializers/operation_groups_serializer.py— addclass_operation_groupsparameter for deduped class-definition renderinggenerator/pygen/codegen/templates/operation_groups_container.py.jinja2— useclass_operation_groupsfor class definitions; keep fulloperation_groupsfor request builder generationSpec enablement
eng/scripts/ci/regenerate-common.ts— removeservice/multiple-servicesfromSKIP_SPECS; add emitter config (package-name,namespace)New tests
Sync + async tests covering all 4 scenarios:
ServiceAClient.operations.op_a,ServiceAClient.sub_namespace.sub_op_a,ServiceBClient.operations.op_b,ServiceBClient.sub_namespace.sub_op_b— each verifying both happy path (correctapi-version→ 204) and rejection (wrongapi-version→HttpResponseError).