From 9bcb7a6d94046a32340c40f4be33150605cdf40c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 6 Mar 2026 08:36:04 +0000 Subject: [PATCH 1/8] Initial plan From 9168ddc95ea5765b5f34a5e3c06abfdc035e6704 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 6 Mar 2026 09:29:51 +0000 Subject: [PATCH 2/8] feat(python): add mock API tests for extensible enum with special word member names Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --- ...ords-extensible-strings-2026-3-6-9-28-8.md | 7 +++++ .../asynctests/test_special_words_async.py | 6 ++++ .../mock_api_tests/test_special_words.py | 5 ++++ .../asynctests/test_special_words_async.py | 6 ++++ .../mock_api_tests/test_special_words.py | 5 ++++ packages/http-client-python/package-lock.json | 28 +++++++++---------- packages/http-client-python/package.json | 2 +- 7 files changed, 44 insertions(+), 15 deletions(-) create mode 100644 .chronus/changes/python-special-words-extensible-strings-2026-3-6-9-28-8.md diff --git a/.chronus/changes/python-special-words-extensible-strings-2026-3-6-9-28-8.md b/.chronus/changes/python-special-words-extensible-strings-2026-3-6-9-28-8.md new file mode 100644 index 00000000000..094e09a7d14 --- /dev/null +++ b/.chronus/changes/python-special-words-extensible-strings-2026-3-6-9-28-8.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-python" +--- + +Add mock API test coverage for extensible enum with special word member names in special-words spec. diff --git a/packages/http-client-python/generator/test/azure/mock_api_tests/asynctests/test_special_words_async.py b/packages/http-client-python/generator/test/azure/mock_api_tests/asynctests/test_special_words_async.py index 9f22c8c5d15..407cac8ff65 100644 --- a/packages/http-client-python/generator/test/azure/mock_api_tests/asynctests/test_special_words_async.py +++ b/packages/http-client-python/generator/test/azure/mock_api_tests/asynctests/test_special_words_async.py @@ -63,3 +63,9 @@ async def test_model_properties_dict_methods(client: SpecialWordsClient): @pytest.mark.asyncio async def test_model_properties_with_list(client: SpecialWordsClient): await client.model_properties.with_list(models.ModelWithList(list="ok")) + + +@pytest.mark.asyncio +async def test_extensible_strings(client: SpecialWordsClient): + result = await client.extensible_strings.put_extensible_string_value(body=models.ExtensibleString.CLASSEnum) + assert result == '"class"' diff --git a/packages/http-client-python/generator/test/azure/mock_api_tests/test_special_words.py b/packages/http-client-python/generator/test/azure/mock_api_tests/test_special_words.py index cc083c94c0e..b2804b4859a 100644 --- a/packages/http-client-python/generator/test/azure/mock_api_tests/test_special_words.py +++ b/packages/http-client-python/generator/test/azure/mock_api_tests/test_special_words.py @@ -56,3 +56,8 @@ def test_model_properties_dict_methods(client: SpecialWordsClient): def test_model_properties_with_list(client: SpecialWordsClient): client.model_properties.with_list(models.ModelWithList(list="ok")) + + +def test_extensible_strings(client: SpecialWordsClient): + result = client.extensible_strings.put_extensible_string_value(body=models.ExtensibleString.CLASSEnum) + assert result == '"class"' diff --git a/packages/http-client-python/generator/test/unbranded/mock_api_tests/asynctests/test_special_words_async.py b/packages/http-client-python/generator/test/unbranded/mock_api_tests/asynctests/test_special_words_async.py index eb11843ab32..dde2aad6404 100644 --- a/packages/http-client-python/generator/test/unbranded/mock_api_tests/asynctests/test_special_words_async.py +++ b/packages/http-client-python/generator/test/unbranded/mock_api_tests/asynctests/test_special_words_async.py @@ -64,3 +64,9 @@ async def test_model_properties_dict_methods(client: SpecialWordsClient): @pytest.mark.asyncio async def test_model_properties_with_list(client: SpecialWordsClient): await client.model_properties.with_list(model_properties_models.ModelWithList(list="ok")) + + +@pytest.mark.asyncio +async def test_extensible_strings(client: SpecialWordsClient): + result = await client.extensible_strings.put_extensible_string_value(body="class") + assert result == '"class"' diff --git a/packages/http-client-python/generator/test/unbranded/mock_api_tests/test_special_words.py b/packages/http-client-python/generator/test/unbranded/mock_api_tests/test_special_words.py index 89679bfd788..e5e720e9767 100644 --- a/packages/http-client-python/generator/test/unbranded/mock_api_tests/test_special_words.py +++ b/packages/http-client-python/generator/test/unbranded/mock_api_tests/test_special_words.py @@ -58,3 +58,8 @@ def test_model_properties_dict_methods(client: SpecialWordsClient): def test_model_properties_with_list(client: SpecialWordsClient): client.model_properties.with_list(model_properties_models.ModelWithList(list="ok")) + + +def test_extensible_strings(client: SpecialWordsClient): + result = client.extensible_strings.put_extensible_string_value(body="class") + assert result == '"class"' diff --git a/packages/http-client-python/package-lock.json b/packages/http-client-python/package-lock.json index 8035b620851..9b1f2e19684 100644 --- a/packages/http-client-python/package-lock.json +++ b/packages/http-client-python/package-lock.json @@ -29,7 +29,7 @@ "@typespec/compiler": "^1.9.0", "@typespec/events": "~0.79.0", "@typespec/http": "^1.9.0", - "@typespec/http-specs": "0.1.0-alpha.33-dev.2", + "@typespec/http-specs": "0.1.0-alpha.33-dev.5", "@typespec/openapi": "^1.9.0", "@typespec/rest": "~0.79.0", "@typespec/spec-api": "0.1.0-alpha.12", @@ -2473,9 +2473,9 @@ } }, "node_modules/@typespec/http": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/@typespec/http/-/http-1.9.0.tgz", - "integrity": "sha512-JzlZZsgCo71f2KhWbf4BLOz5e+dVLj7gJJ4kvXvrmuG9QHoT41VaGPpCQamYgpZLMz2LQbsOtw34AmpovhuJSw==", + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/@typespec/http/-/http-1.9.1.tgz", + "integrity": "sha512-agcwmbB/hK/o9KmM38UB8OGZwLgB17lJ7b4EjqYGpyshqcRMTESMRxnJIH7rRzUq4HJDTqal0tsb8z0K0zXuDg==", "dev": true, "license": "MIT", "engines": { @@ -2492,25 +2492,25 @@ } }, "node_modules/@typespec/http-specs": { - "version": "0.1.0-alpha.33-dev.2", - "resolved": "https://registry.npmjs.org/@typespec/http-specs/-/http-specs-0.1.0-alpha.33-dev.2.tgz", - "integrity": "sha512-Ex7PVBJgJAmNLKMbp9jA6+fXalcau3Rf+J7N8XMwCICvz6yFcRJKF07/NsM3Doc87e43VovnrJb2I2tb7LSuDw==", + "version": "0.1.0-alpha.33-dev.5", + "resolved": "https://registry.npmjs.org/@typespec/http-specs/-/http-specs-0.1.0-alpha.33-dev.5.tgz", + "integrity": "sha512-C5lg4ZF2BC5b4mebR32iID+zaETSJQyDEu+vVjSGOp7BjlpviFhgLYw3zMwI8u8Q0FVUAW1WvVVjRZ5X/X74GA==", "dev": true, "license": "MIT", "dependencies": { - "@typespec/spec-api": "^0.1.0-alpha.12 || >=0.1.0-alpha.13-dev <0.1.0-alpha.13", - "@typespec/spector": "^0.1.0-alpha.23 || >=0.1.0-alpha.24-dev <0.1.0-alpha.24", + "@typespec/spec-api": "^0.1.0-alpha.12 || >= 0.1.0-alpha.13-dev.1", + "@typespec/spector": "^0.1.0-alpha.23 || >= 0.1.0-alpha.24-dev.4", "deep-equal": "^2.2.0" }, "engines": { "node": ">=16.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.9.0", - "@typespec/http": "^1.9.0", - "@typespec/rest": "^0.79.0 || >=0.80.0-dev <0.80.0", - "@typespec/versioning": "^0.79.0 || >=0.80.0-dev <0.80.0", - "@typespec/xml": "^0.79.0 || >=0.80.0-dev <0.80.0" + "@typespec/compiler": "^1.9.0 || >= 1.10.0-dev.15", + "@typespec/http": "^1.9.1 || >= 1.10.0-dev.5", + "@typespec/rest": "^0.79.0 || >= 0.80.0-dev.2", + "@typespec/versioning": "^0.79.0 || >= 0.80.0-dev.3", + "@typespec/xml": "^0.79.0 || >= 0.80.0-dev.2" } }, "node_modules/@typespec/openapi": { diff --git a/packages/http-client-python/package.json b/packages/http-client-python/package.json index 39b23f709d7..98317bb4d05 100644 --- a/packages/http-client-python/package.json +++ b/packages/http-client-python/package.json @@ -94,7 +94,7 @@ "@typespec/sse": "~0.79.0", "@typespec/streams": "~0.79.0", "@typespec/xml": "~0.79.0", - "@typespec/http-specs": "0.1.0-alpha.33-dev.2", + "@typespec/http-specs": "0.1.0-alpha.33-dev.5", "@types/js-yaml": "~4.0.5", "@types/node": "~25.0.2", "@types/semver": "7.5.8", From 67e797da83a98822fb98796956400ec3d2697874 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 6 Mar 2026 12:09:41 +0000 Subject: [PATCH 3/8] fix(python): remove incorrect Enum suffix from extensible enum member names Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --- .../http-client-python/generator/pygen/preprocess/__init__.py | 3 ++- .../mock_api_tests/asynctests/test_special_words_async.py | 2 +- .../generator/test/azure/mock_api_tests/test_special_words.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/http-client-python/generator/pygen/preprocess/__init__.py b/packages/http-client-python/generator/pygen/preprocess/__init__.py index e2f8cf842b3..5a784c2a783 100644 --- a/packages/http-client-python/generator/pygen/preprocess/__init__.py +++ b/packages/http-client-python/generator/pygen/preprocess/__init__.py @@ -4,6 +4,7 @@ # license information. # -------------------------------------------------------------------------- """The preprocessing autorest plugin.""" + import copy from typing import Callable, Any, Optional @@ -264,7 +265,7 @@ def update_types(self, yaml_data: list[dict[str, Any]]) -> None: property["clientName"].lower(), PadType.PROPERTY, property ) add_redefined_builtin_info(property["clientName"], property) - if type.get("name"): + if type.get("name") and type["type"] != "enumvalue": pad_type = PadType.MODEL if type["type"] == "model" else PadType.ENUM_CLASS name = self.pad_reserved_words(type["name"], pad_type, type) type["name"] = name[0].upper() + name[1:] diff --git a/packages/http-client-python/generator/test/azure/mock_api_tests/asynctests/test_special_words_async.py b/packages/http-client-python/generator/test/azure/mock_api_tests/asynctests/test_special_words_async.py index 407cac8ff65..fa2727d3310 100644 --- a/packages/http-client-python/generator/test/azure/mock_api_tests/asynctests/test_special_words_async.py +++ b/packages/http-client-python/generator/test/azure/mock_api_tests/asynctests/test_special_words_async.py @@ -67,5 +67,5 @@ async def test_model_properties_with_list(client: SpecialWordsClient): @pytest.mark.asyncio async def test_extensible_strings(client: SpecialWordsClient): - result = await client.extensible_strings.put_extensible_string_value(body=models.ExtensibleString.CLASSEnum) + result = await client.extensible_strings.put_extensible_string_value(body=models.ExtensibleString.CLASS) assert result == '"class"' diff --git a/packages/http-client-python/generator/test/azure/mock_api_tests/test_special_words.py b/packages/http-client-python/generator/test/azure/mock_api_tests/test_special_words.py index b2804b4859a..053aaa87c2d 100644 --- a/packages/http-client-python/generator/test/azure/mock_api_tests/test_special_words.py +++ b/packages/http-client-python/generator/test/azure/mock_api_tests/test_special_words.py @@ -59,5 +59,5 @@ def test_model_properties_with_list(client: SpecialWordsClient): def test_extensible_strings(client: SpecialWordsClient): - result = client.extensible_strings.put_extensible_string_value(body=models.ExtensibleString.CLASSEnum) + result = client.extensible_strings.put_extensible_string_value(body=models.ExtensibleString.CLASS) assert result == '"class"' From 504047b318bbf7fb140b7b398a8d50eb6b5a8b64 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 6 Mar 2026 12:13:19 +0000 Subject: [PATCH 4/8] chore: add changelog entry for enum member reserved-word suffix fix Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --- ...enum-member-reserved-word-suffix-2026-03-06-12-00-00.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .chronus/changes/python-fix-enum-member-reserved-word-suffix-2026-03-06-12-00-00.md diff --git a/.chronus/changes/python-fix-enum-member-reserved-word-suffix-2026-03-06-12-00-00.md b/.chronus/changes/python-fix-enum-member-reserved-word-suffix-2026-03-06-12-00-00.md new file mode 100644 index 00000000000..c3ed9c2c4e2 --- /dev/null +++ b/.chronus/changes/python-fix-enum-member-reserved-word-suffix-2026-03-06-12-00-00.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@typespec/http-client-python" +--- + +Fix extensible enum member names incorrectly getting an `Enum` suffix when the member name matched a Python reserved word (e.g. `ANDEnum` → `AND`, `CLASSEnum` → `CLASS`). From 9b100c888cd11e46e26c3df465f48d17a8978a6d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 6 Mar 2026 13:44:25 +0000 Subject: [PATCH 5/8] fix(python): fix models __init__.py overwrite when operation group shares models folder path Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --- ...space-models-init-overwrite-2026-03-06-13-00-00.md | 7 +++++++ .../generator/pygen/codegen/serializers/__init__.py | 11 ++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 .chronus/changes/python-fix-namespace-models-init-overwrite-2026-03-06-13-00-00.md diff --git a/.chronus/changes/python-fix-namespace-models-init-overwrite-2026-03-06-13-00-00.md b/.chronus/changes/python-fix-namespace-models-init-overwrite-2026-03-06-13-00-00.md new file mode 100644 index 00000000000..ae78fd05062 --- /dev/null +++ b/.chronus/changes/python-fix-namespace-models-init-overwrite-2026-03-06-13-00-00.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@typespec/http-client-python" +--- + +Fix generated `models/__init__.py` being overwritten with a pkgutil namespace init when an operation group shares the same directory path as the models folder (e.g. a `Models` operation group conflicting with `specialwords/models/`). This caused `ImportError` when importing the generated client. diff --git a/packages/http-client-python/generator/pygen/codegen/serializers/__init__.py b/packages/http-client-python/generator/pygen/codegen/serializers/__init__.py index 6a16ed93e48..fa0fdc4a90f 100644 --- a/packages/http-client-python/generator/pygen/codegen/serializers/__init__.py +++ b/packages/http-client-python/generator/pygen/codegen/serializers/__init__.py @@ -143,7 +143,16 @@ def serialize(self) -> None: ) general_serializer = GeneralSerializer(code_model=self.code_model, env=env, async_mode=False) - for client_namespace, client_namespace_type in self.code_model.client_namespace_types.items(): + # Process namespaces deepest-first so that shallower namespaces (which write the models + # folder __init__.py) always overwrite the pkgutil namespace init written by deeper + # sub-namespaces that share the same directory path (e.g. an operation group named + # "models" that lives under the same "specialwords/models/" folder as the data models). + # The empty root namespace ("") is treated as depth 0 and processed last. + for client_namespace, client_namespace_type in sorted( + self.code_model.client_namespace_types.items(), + key=lambda x: len(x[0].split(".")) if x[0] else 0, + reverse=True, + ): generation_path = self.code_model.get_generation_dir(client_namespace) if client_namespace == "": if self.code_model.options["basic-setup-py"]: From e808d1acd7f221b780cf161fc9c4bb65cb9e4cdf Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Mon, 9 Mar 2026 13:59:34 +0800 Subject: [PATCH 6/8] Revert "fix(python): fix models __init__.py overwrite when operation group shares models folder path" This reverts commit 9b100c888cd11e46e26c3df465f48d17a8978a6d. --- ...space-models-init-overwrite-2026-03-06-13-00-00.md | 7 ------- .../generator/pygen/codegen/serializers/__init__.py | 11 +---------- 2 files changed, 1 insertion(+), 17 deletions(-) delete mode 100644 .chronus/changes/python-fix-namespace-models-init-overwrite-2026-03-06-13-00-00.md diff --git a/.chronus/changes/python-fix-namespace-models-init-overwrite-2026-03-06-13-00-00.md b/.chronus/changes/python-fix-namespace-models-init-overwrite-2026-03-06-13-00-00.md deleted file mode 100644 index ae78fd05062..00000000000 --- a/.chronus/changes/python-fix-namespace-models-init-overwrite-2026-03-06-13-00-00.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -changeKind: fix -packages: - - "@typespec/http-client-python" ---- - -Fix generated `models/__init__.py` being overwritten with a pkgutil namespace init when an operation group shares the same directory path as the models folder (e.g. a `Models` operation group conflicting with `specialwords/models/`). This caused `ImportError` when importing the generated client. diff --git a/packages/http-client-python/generator/pygen/codegen/serializers/__init__.py b/packages/http-client-python/generator/pygen/codegen/serializers/__init__.py index fa0fdc4a90f..6a16ed93e48 100644 --- a/packages/http-client-python/generator/pygen/codegen/serializers/__init__.py +++ b/packages/http-client-python/generator/pygen/codegen/serializers/__init__.py @@ -143,16 +143,7 @@ def serialize(self) -> None: ) general_serializer = GeneralSerializer(code_model=self.code_model, env=env, async_mode=False) - # Process namespaces deepest-first so that shallower namespaces (which write the models - # folder __init__.py) always overwrite the pkgutil namespace init written by deeper - # sub-namespaces that share the same directory path (e.g. an operation group named - # "models" that lives under the same "specialwords/models/" folder as the data models). - # The empty root namespace ("") is treated as depth 0 and processed last. - for client_namespace, client_namespace_type in sorted( - self.code_model.client_namespace_types.items(), - key=lambda x: len(x[0].split(".")) if x[0] else 0, - reverse=True, - ): + for client_namespace, client_namespace_type in self.code_model.client_namespace_types.items(): generation_path = self.code_model.get_generation_dir(client_namespace) if client_namespace == "": if self.code_model.options["basic-setup-py"]: From 60736bbe2c02bdb974609d7c5f46733ca0463dce Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Mon, 9 Mar 2026 07:34:34 +0000 Subject: [PATCH 7/8] update test case --- .../asynctests/test_special_words_async.py | 5 +-- .../mock_api_tests/test_special_words.py | 5 +-- .../asynctests/test_special_words_async.py | 5 +-- .../mock_api_tests/test_special_words.py | 5 +-- .../generator/test/unittests/test_enums.py | 36 +++++++++++++++++++ 5 files changed, 48 insertions(+), 8 deletions(-) diff --git a/packages/http-client-python/generator/test/azure/mock_api_tests/asynctests/test_special_words_async.py b/packages/http-client-python/generator/test/azure/mock_api_tests/asynctests/test_special_words_async.py index fa2727d3310..6250a2e7dbf 100644 --- a/packages/http-client-python/generator/test/azure/mock_api_tests/asynctests/test_special_words_async.py +++ b/packages/http-client-python/generator/test/azure/mock_api_tests/asynctests/test_special_words_async.py @@ -6,6 +6,7 @@ import pytest from specialwords.aio import SpecialWordsClient from specialwords import models +from specialwords.extensiblestrings import models as extensible_strings_models @pytest.fixture @@ -67,5 +68,5 @@ async def test_model_properties_with_list(client: SpecialWordsClient): @pytest.mark.asyncio async def test_extensible_strings(client: SpecialWordsClient): - result = await client.extensible_strings.put_extensible_string_value(body=models.ExtensibleString.CLASS) - assert result == '"class"' + for enum_value in extensible_strings_models.ExtensibleString: + assert await client.extensible_strings.put_extensible_string_value(body=enum_value) diff --git a/packages/http-client-python/generator/test/azure/mock_api_tests/test_special_words.py b/packages/http-client-python/generator/test/azure/mock_api_tests/test_special_words.py index 053aaa87c2d..b7d0d886598 100644 --- a/packages/http-client-python/generator/test/azure/mock_api_tests/test_special_words.py +++ b/packages/http-client-python/generator/test/azure/mock_api_tests/test_special_words.py @@ -5,6 +5,7 @@ # -------------------------------------------------------------------------- import pytest from specialwords import SpecialWordsClient, models +from specialwords.extensiblestrings import models as extensible_strings_models @pytest.fixture @@ -59,5 +60,5 @@ def test_model_properties_with_list(client: SpecialWordsClient): def test_extensible_strings(client: SpecialWordsClient): - result = client.extensible_strings.put_extensible_string_value(body=models.ExtensibleString.CLASS) - assert result == '"class"' + for enum_value in extensible_strings_models.ExtensibleString: + assert client.extensible_strings.put_extensible_string_value(body=enum_value) diff --git a/packages/http-client-python/generator/test/unbranded/mock_api_tests/asynctests/test_special_words_async.py b/packages/http-client-python/generator/test/unbranded/mock_api_tests/asynctests/test_special_words_async.py index dde2aad6404..016ad818c89 100644 --- a/packages/http-client-python/generator/test/unbranded/mock_api_tests/asynctests/test_special_words_async.py +++ b/packages/http-client-python/generator/test/unbranded/mock_api_tests/asynctests/test_special_words_async.py @@ -7,6 +7,7 @@ from specialwords.aio import SpecialWordsClient from specialwords.models import models from specialwords.modelproperties import models as model_properties_models +from specialwords.extensiblestrings import models as extensible_strings_models @pytest.fixture @@ -68,5 +69,5 @@ async def test_model_properties_with_list(client: SpecialWordsClient): @pytest.mark.asyncio async def test_extensible_strings(client: SpecialWordsClient): - result = await client.extensible_strings.put_extensible_string_value(body="class") - assert result == '"class"' + for enum_value in extensible_strings_models.ExtensibleString: + assert await client.extensible_strings.put_extensible_string_value(body=enum_value) diff --git a/packages/http-client-python/generator/test/unbranded/mock_api_tests/test_special_words.py b/packages/http-client-python/generator/test/unbranded/mock_api_tests/test_special_words.py index e5e720e9767..865e53a29fc 100644 --- a/packages/http-client-python/generator/test/unbranded/mock_api_tests/test_special_words.py +++ b/packages/http-client-python/generator/test/unbranded/mock_api_tests/test_special_words.py @@ -7,6 +7,7 @@ from specialwords import SpecialWordsClient from specialwords.models import models from specialwords.modelproperties import models as model_properties_models +from specialwords.extensiblestrings import models as extensible_strings_models @pytest.fixture @@ -61,5 +62,5 @@ def test_model_properties_with_list(client: SpecialWordsClient): def test_extensible_strings(client: SpecialWordsClient): - result = client.extensible_strings.put_extensible_string_value(body="class") - assert result == '"class"' + for enum_value in extensible_strings_models.ExtensibleString: + assert client.extensible_strings.put_extensible_string_value(body=enum_value) diff --git a/packages/http-client-python/generator/test/unittests/test_enums.py b/packages/http-client-python/generator/test/unittests/test_enums.py index 02134609523..47572b9cefb 100644 --- a/packages/http-client-python/generator/test/unittests/test_enums.py +++ b/packages/http-client-python/generator/test/unittests/test_enums.py @@ -4,6 +4,7 @@ # license information. # -------------------------------------------------------------------------- from enum import Enum, EnumMeta +from specialwords.extensiblestrings import models as extensible_strings_models class _CaseInsensitiveEnumMeta(EnumMeta): @@ -50,3 +51,38 @@ def test_find(): def test_join(): assert EnumsWithCallableNames.JOIN == "join" assert callable(EnumsWithCallableNames.join) + +def test_extensible_strings_enum_with_special_words(): + assert extensible_strings_models.ExtensibleString.AND == "and" + assert extensible_strings_models.ExtensibleString.AS == "as" + assert extensible_strings_models.ExtensibleString.ASSERT == "assert" + assert extensible_strings_models.ExtensibleString.ASYNC == "async" + assert extensible_strings_models.ExtensibleString.AWAIT == "await" + assert extensible_strings_models.ExtensibleString.BREAK == "break" + assert extensible_strings_models.ExtensibleString.CLASS == "class" + assert extensible_strings_models.ExtensibleString.CONSTRUCTOR == "constructor" + assert extensible_strings_models.ExtensibleString.CONTINUE == "continue" + assert extensible_strings_models.ExtensibleString.DEF == "def" + assert extensible_strings_models.ExtensibleString.DEL == "del" + assert extensible_strings_models.ExtensibleString.ELIF == "elif" + assert extensible_strings_models.ExtensibleString.ELSE == "else" + assert extensible_strings_models.ExtensibleString.EXCEPT == "except" + assert extensible_strings_models.ExtensibleString.EXEC == "exec" + assert extensible_strings_models.ExtensibleString.FINALLY == "finally" + assert extensible_strings_models.ExtensibleString.FOR == "for" + assert extensible_strings_models.ExtensibleString.FROM == "from" + assert extensible_strings_models.ExtensibleString.GLOBAL == "global" + assert extensible_strings_models.ExtensibleString.IF == "if" + assert extensible_strings_models.ExtensibleString.IMPORT == "import" + assert extensible_strings_models.ExtensibleString.IN == "in" + assert extensible_strings_models.ExtensibleString.IS == "is" + assert extensible_strings_models.ExtensibleString.LAMBDA == "lambda" + assert extensible_strings_models.ExtensibleString.NOT == "not" + assert extensible_strings_models.ExtensibleString.OR == "or" + assert extensible_strings_models.ExtensibleString.PASS == "pass" + assert extensible_strings_models.ExtensibleString.RAISE == "raise" + assert extensible_strings_models.ExtensibleString.RETURN == "return" + assert extensible_strings_models.ExtensibleString.TRY == "try" + assert extensible_strings_models.ExtensibleString.WHILE == "while" + assert extensible_strings_models.ExtensibleString.WITH == "with" + assert extensible_strings_models.ExtensibleString.YIELD == "yield" \ No newline at end of file From 1bcf463444be06b7f773b6e074cfce63be477038 Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Mon, 9 Mar 2026 07:36:29 +0000 Subject: [PATCH 8/8] Update special words assertions across tests --- .../mock_api_tests/asynctests/test_special_words_async.py | 2 +- .../generator/test/azure/mock_api_tests/test_special_words.py | 2 +- .../mock_api_tests/asynctests/test_special_words_async.py | 2 +- .../test/unbranded/mock_api_tests/test_special_words.py | 2 +- .../http-client-python/generator/test/unittests/test_enums.py | 3 ++- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/http-client-python/generator/test/azure/mock_api_tests/asynctests/test_special_words_async.py b/packages/http-client-python/generator/test/azure/mock_api_tests/asynctests/test_special_words_async.py index 6250a2e7dbf..39a150e4db9 100644 --- a/packages/http-client-python/generator/test/azure/mock_api_tests/asynctests/test_special_words_async.py +++ b/packages/http-client-python/generator/test/azure/mock_api_tests/asynctests/test_special_words_async.py @@ -69,4 +69,4 @@ async def test_model_properties_with_list(client: SpecialWordsClient): @pytest.mark.asyncio async def test_extensible_strings(client: SpecialWordsClient): for enum_value in extensible_strings_models.ExtensibleString: - assert await client.extensible_strings.put_extensible_string_value(body=enum_value) + assert enum_value == await client.extensible_strings.put_extensible_string_value(body=enum_value) diff --git a/packages/http-client-python/generator/test/azure/mock_api_tests/test_special_words.py b/packages/http-client-python/generator/test/azure/mock_api_tests/test_special_words.py index b7d0d886598..2f591680bb2 100644 --- a/packages/http-client-python/generator/test/azure/mock_api_tests/test_special_words.py +++ b/packages/http-client-python/generator/test/azure/mock_api_tests/test_special_words.py @@ -61,4 +61,4 @@ def test_model_properties_with_list(client: SpecialWordsClient): def test_extensible_strings(client: SpecialWordsClient): for enum_value in extensible_strings_models.ExtensibleString: - assert client.extensible_strings.put_extensible_string_value(body=enum_value) + assert enum_value == client.extensible_strings.put_extensible_string_value(body=enum_value) diff --git a/packages/http-client-python/generator/test/unbranded/mock_api_tests/asynctests/test_special_words_async.py b/packages/http-client-python/generator/test/unbranded/mock_api_tests/asynctests/test_special_words_async.py index 016ad818c89..112533fa2db 100644 --- a/packages/http-client-python/generator/test/unbranded/mock_api_tests/asynctests/test_special_words_async.py +++ b/packages/http-client-python/generator/test/unbranded/mock_api_tests/asynctests/test_special_words_async.py @@ -70,4 +70,4 @@ async def test_model_properties_with_list(client: SpecialWordsClient): @pytest.mark.asyncio async def test_extensible_strings(client: SpecialWordsClient): for enum_value in extensible_strings_models.ExtensibleString: - assert await client.extensible_strings.put_extensible_string_value(body=enum_value) + assert enum_value == await client.extensible_strings.put_extensible_string_value(body=enum_value) diff --git a/packages/http-client-python/generator/test/unbranded/mock_api_tests/test_special_words.py b/packages/http-client-python/generator/test/unbranded/mock_api_tests/test_special_words.py index 865e53a29fc..83269cc1e47 100644 --- a/packages/http-client-python/generator/test/unbranded/mock_api_tests/test_special_words.py +++ b/packages/http-client-python/generator/test/unbranded/mock_api_tests/test_special_words.py @@ -63,4 +63,4 @@ def test_model_properties_with_list(client: SpecialWordsClient): def test_extensible_strings(client: SpecialWordsClient): for enum_value in extensible_strings_models.ExtensibleString: - assert client.extensible_strings.put_extensible_string_value(body=enum_value) + assert enum_value == client.extensible_strings.put_extensible_string_value(body=enum_value) diff --git a/packages/http-client-python/generator/test/unittests/test_enums.py b/packages/http-client-python/generator/test/unittests/test_enums.py index 47572b9cefb..2b671c90996 100644 --- a/packages/http-client-python/generator/test/unittests/test_enums.py +++ b/packages/http-client-python/generator/test/unittests/test_enums.py @@ -52,6 +52,7 @@ def test_join(): assert EnumsWithCallableNames.JOIN == "join" assert callable(EnumsWithCallableNames.join) + def test_extensible_strings_enum_with_special_words(): assert extensible_strings_models.ExtensibleString.AND == "and" assert extensible_strings_models.ExtensibleString.AS == "as" @@ -85,4 +86,4 @@ def test_extensible_strings_enum_with_special_words(): assert extensible_strings_models.ExtensibleString.TRY == "try" assert extensible_strings_models.ExtensibleString.WHILE == "while" assert extensible_strings_models.ExtensibleString.WITH == "with" - assert extensible_strings_models.ExtensibleString.YIELD == "yield" \ No newline at end of file + assert extensible_strings_models.ExtensibleString.YIELD == "yield"