From 952ccaf7e92f76c0ba3974153371f62a414b2fbe Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 4 Jun 2026 09:09:34 +0000 Subject: [PATCH 1/6] Initial plan From 1d4e7b4e37565d97321b05c0d5d1f7a4f245dfc2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 4 Jun 2026 09:14:01 +0000 Subject: [PATCH 2/6] Plan: add python tests for client-doc and response-as-bool spector cases Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --- packages/http-client-python/package-lock.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/http-client-python/package-lock.json b/packages/http-client-python/package-lock.json index abed8fc89d7..9f3003270fb 100644 --- a/packages/http-client-python/package-lock.json +++ b/packages/http-client-python/package-lock.json @@ -1,12 +1,12 @@ { "name": "@typespec/http-client-python", - "version": "0.30.0", + "version": "0.30.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@typespec/http-client-python", - "version": "0.30.0", + "version": "0.30.1", "hasInstallScript": true, "license": "MIT", "dependencies": { From 175dd91951ff170c62b55155a883cf1d0f382348 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 4 Jun 2026 09:18:30 +0000 Subject: [PATCH 3/6] Add python tests for client-doc spector case (Azure PR #4268) Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --- .../python-client-doc-test-2026-6-4-9-30-0.md | 7 ++++ ..._client_generator_core_client_doc_async.py | 34 +++++++++++++++++++ ..._azure_client_generator_core_client_doc.py | 31 +++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 .chronus/changes/python-client-doc-test-2026-6-4-9-30-0.md create mode 100644 packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_client_doc_async.py create mode 100644 packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_client_doc.py diff --git a/.chronus/changes/python-client-doc-test-2026-6-4-9-30-0.md b/.chronus/changes/python-client-doc-test-2026-6-4-9-30-0.md new file mode 100644 index 00000000000..84dd98fac83 --- /dev/null +++ b/.chronus/changes/python-client-doc-test-2026-6-4-9-30-0.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-python" +--- + +Add test for the `@clientDoc` decorator spector case (azure/client-generator-core/client-doc). diff --git a/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_client_doc_async.py b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_client_doc_async.py new file mode 100644 index 00000000000..b9334c6f4cf --- /dev/null +++ b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_client_doc_async.py @@ -0,0 +1,34 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import pytest +import pytest_asyncio +from specs.azure.clientgenerator.core.clientdoc.aio import ClientDocClient +from specs.azure.clientgenerator.core.clientdoc import models + + +@pytest_asyncio.fixture +async def client(): + async with ClientDocClient() as client: + yield client + + +@pytest.mark.asyncio +async def test_harvest(client: ClientDocClient): + body = models.Plant(name="Rose", species="Rosa") + assert await client.documentation.harvest(body) == body + + +def test_model_doc_appended(): + # @clientDoc in append mode keeps the base @doc and appends the client-specific text. + assert "A plant in the garden." in models.Plant.__doc__ + assert "This model is used to represent a plant in the client SDK." in models.Plant.__doc__ + + +@pytest.mark.asyncio +async def test_operation_doc_replaced(client: ClientDocClient): + # @clientDoc in replace mode overrides the base @doc completely. + assert "Retrieves a plant from the garden by submitting its name." in client.documentation.harvest.__doc__ + assert "Internal operation to get a plant." not in client.documentation.harvest.__doc__ diff --git a/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_client_doc.py b/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_client_doc.py new file mode 100644 index 00000000000..299360a9e85 --- /dev/null +++ b/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_client_doc.py @@ -0,0 +1,31 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import pytest +from specs.azure.clientgenerator.core.clientdoc import ClientDocClient +from specs.azure.clientgenerator.core.clientdoc import models + + +@pytest.fixture +def client(): + with ClientDocClient() as client: + yield client + + +def test_harvest(client: ClientDocClient): + body = models.Plant(name="Rose", species="Rosa") + assert client.documentation.harvest(body) == body + + +def test_model_doc_appended(): + # @clientDoc in append mode keeps the base @doc and appends the client-specific text. + assert "A plant in the garden." in models.Plant.__doc__ + assert "This model is used to represent a plant in the client SDK." in models.Plant.__doc__ + + +def test_operation_doc_replaced(client: ClientDocClient): + # @clientDoc in replace mode overrides the base @doc completely. + assert "Retrieves a plant from the garden by submitting its name." in client.documentation.harvest.__doc__ + assert "Internal operation to get a plant." not in client.documentation.harvest.__doc__ From add5d5e7c2971f0e90ab34d6746b8d0f8f50b84f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 9 Jun 2026 09:31:08 +0000 Subject: [PATCH 4/6] Compare whole docstring instead of substrings in client-doc tests Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --- ..._client_generator_core_client_doc_async.py | 23 +++++++++++++++---- ..._azure_client_generator_core_client_doc.py | 23 +++++++++++++++---- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_client_doc_async.py b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_client_doc_async.py index b9334c6f4cf..6ba7673a6d6 100644 --- a/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_client_doc_async.py +++ b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_client_doc_async.py @@ -23,12 +23,27 @@ async def test_harvest(client: ClientDocClient): def test_model_doc_appended(): # @clientDoc in append mode keeps the base @doc and appends the client-specific text. - assert "A plant in the garden." in models.Plant.__doc__ - assert "This model is used to represent a plant in the client SDK." in models.Plant.__doc__ + assert models.Plant.__doc__ == ( + "A plant in the garden. This model is used to represent a plant in the client SDK.\n" + "\n" + " :ivar name: The name of the plant. Required.\n" + " :vartype name: str\n" + " :ivar species: The species of the plant. Required.\n" + " :vartype species: str\n" + " " + ) @pytest.mark.asyncio async def test_operation_doc_replaced(client: ClientDocClient): # @clientDoc in replace mode overrides the base @doc completely. - assert "Retrieves a plant from the garden by submitting its name." in client.documentation.harvest.__doc__ - assert "Internal operation to get a plant." not in client.documentation.harvest.__doc__ + assert client.documentation.harvest.__doc__ == ( + "Retrieves a plant from the garden by submitting its name.\n" + "\n" + " :param body: Is one of the following types: Plant, JSON, IO[bytes] Required.\n" + " :type body: ~specs.azure.clientgenerator.core.clientdoc.models.Plant or JSON or IO[bytes]\n" + " :return: Plant. The Plant is compatible with MutableMapping\n" + " :rtype: ~specs.azure.clientgenerator.core.clientdoc.models.Plant\n" + " :raises ~azure.core.exceptions.HttpResponseError:\n" + " " + ) diff --git a/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_client_doc.py b/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_client_doc.py index 299360a9e85..c593833dbf6 100644 --- a/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_client_doc.py +++ b/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_client_doc.py @@ -21,11 +21,26 @@ def test_harvest(client: ClientDocClient): def test_model_doc_appended(): # @clientDoc in append mode keeps the base @doc and appends the client-specific text. - assert "A plant in the garden." in models.Plant.__doc__ - assert "This model is used to represent a plant in the client SDK." in models.Plant.__doc__ + assert models.Plant.__doc__ == ( + "A plant in the garden. This model is used to represent a plant in the client SDK.\n" + "\n" + " :ivar name: The name of the plant. Required.\n" + " :vartype name: str\n" + " :ivar species: The species of the plant. Required.\n" + " :vartype species: str\n" + " " + ) def test_operation_doc_replaced(client: ClientDocClient): # @clientDoc in replace mode overrides the base @doc completely. - assert "Retrieves a plant from the garden by submitting its name." in client.documentation.harvest.__doc__ - assert "Internal operation to get a plant." not in client.documentation.harvest.__doc__ + assert client.documentation.harvest.__doc__ == ( + "Retrieves a plant from the garden by submitting its name.\n" + "\n" + " :param body: Is one of the following types: Plant, JSON, IO[bytes] Required.\n" + " :type body: ~specs.azure.clientgenerator.core.clientdoc.models.Plant or JSON or IO[bytes]\n" + " :return: Plant. The Plant is compatible with MutableMapping\n" + " :rtype: ~specs.azure.clientgenerator.core.clientdoc.models.Plant\n" + " :raises ~azure.core.exceptions.HttpResponseError:\n" + " " + ) From 9a6d9ed85e2cce42d43aa0974fa5c3453651b52e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 9 Jun 2026 09:33:19 +0000 Subject: [PATCH 5/6] Document trailing docstring indentation in client-doc test assertions Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --- .../test_azure_client_generator_core_client_doc_async.py | 2 ++ .../azure/test_azure_client_generator_core_client_doc.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_client_doc_async.py b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_client_doc_async.py index 6ba7673a6d6..ff39d7d73d0 100644 --- a/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_client_doc_async.py +++ b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_client_doc_async.py @@ -23,6 +23,7 @@ async def test_harvest(client: ClientDocClient): def test_model_doc_appended(): # @clientDoc in append mode keeps the base @doc and appends the client-specific text. + # The full docstring is compared, including the trailing indentation that closes the docstring. assert models.Plant.__doc__ == ( "A plant in the garden. This model is used to represent a plant in the client SDK.\n" "\n" @@ -37,6 +38,7 @@ def test_model_doc_appended(): @pytest.mark.asyncio async def test_operation_doc_replaced(client: ClientDocClient): # @clientDoc in replace mode overrides the base @doc completely. + # The full docstring is compared, including the trailing indentation that closes the docstring. assert client.documentation.harvest.__doc__ == ( "Retrieves a plant from the garden by submitting its name.\n" "\n" diff --git a/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_client_doc.py b/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_client_doc.py index c593833dbf6..9fdff7f9cbf 100644 --- a/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_client_doc.py +++ b/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_client_doc.py @@ -21,6 +21,7 @@ def test_harvest(client: ClientDocClient): def test_model_doc_appended(): # @clientDoc in append mode keeps the base @doc and appends the client-specific text. + # The full docstring is compared, including the trailing indentation that closes the docstring. assert models.Plant.__doc__ == ( "A plant in the garden. This model is used to represent a plant in the client SDK.\n" "\n" @@ -34,6 +35,7 @@ def test_model_doc_appended(): def test_operation_doc_replaced(client: ClientDocClient): # @clientDoc in replace mode overrides the base @doc completely. + # The full docstring is compared, including the trailing indentation that closes the docstring. assert client.documentation.harvest.__doc__ == ( "Retrieves a plant from the garden by submitting its name.\n" "\n" From 983e99162fc843aaa140d12d68041179fbd0a116 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 10 Jun 2026 04:01:01 +0000 Subject: [PATCH 6/6] Compare only method/model description in client-doc tests Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --- ..._client_generator_core_client_doc_async.py | 27 +++++-------------- ..._azure_client_generator_core_client_doc.py | 27 +++++-------------- 2 files changed, 12 insertions(+), 42 deletions(-) diff --git a/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_client_doc_async.py b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_client_doc_async.py index ff39d7d73d0..ee0c114ec5e 100644 --- a/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_client_doc_async.py +++ b/packages/http-client-python/tests/mock_api/azure/asynctests/test_azure_client_generator_core_client_doc_async.py @@ -23,29 +23,14 @@ async def test_harvest(client: ClientDocClient): def test_model_doc_appended(): # @clientDoc in append mode keeps the base @doc and appends the client-specific text. - # The full docstring is compared, including the trailing indentation that closes the docstring. - assert models.Plant.__doc__ == ( - "A plant in the garden. This model is used to represent a plant in the client SDK.\n" - "\n" - " :ivar name: The name of the plant. Required.\n" - " :vartype name: str\n" - " :ivar species: The species of the plant. Required.\n" - " :vartype species: str\n" - " " - ) + # Only the model description is compared, not the parameter docstrings. + doc = models.Plant.__doc__.split(":ivar")[0].strip() + assert doc == "A plant in the garden. This model is used to represent a plant in the client SDK." @pytest.mark.asyncio async def test_operation_doc_replaced(client: ClientDocClient): # @clientDoc in replace mode overrides the base @doc completely. - # The full docstring is compared, including the trailing indentation that closes the docstring. - assert client.documentation.harvest.__doc__ == ( - "Retrieves a plant from the garden by submitting its name.\n" - "\n" - " :param body: Is one of the following types: Plant, JSON, IO[bytes] Required.\n" - " :type body: ~specs.azure.clientgenerator.core.clientdoc.models.Plant or JSON or IO[bytes]\n" - " :return: Plant. The Plant is compatible with MutableMapping\n" - " :rtype: ~specs.azure.clientgenerator.core.clientdoc.models.Plant\n" - " :raises ~azure.core.exceptions.HttpResponseError:\n" - " " - ) + # Only the operation description is compared, not the parameter docstrings. + doc = client.documentation.harvest.__doc__.split(":param")[0].strip() + assert doc == "Retrieves a plant from the garden by submitting its name." diff --git a/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_client_doc.py b/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_client_doc.py index 9fdff7f9cbf..edc5575f2f0 100644 --- a/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_client_doc.py +++ b/packages/http-client-python/tests/mock_api/azure/test_azure_client_generator_core_client_doc.py @@ -21,28 +21,13 @@ def test_harvest(client: ClientDocClient): def test_model_doc_appended(): # @clientDoc in append mode keeps the base @doc and appends the client-specific text. - # The full docstring is compared, including the trailing indentation that closes the docstring. - assert models.Plant.__doc__ == ( - "A plant in the garden. This model is used to represent a plant in the client SDK.\n" - "\n" - " :ivar name: The name of the plant. Required.\n" - " :vartype name: str\n" - " :ivar species: The species of the plant. Required.\n" - " :vartype species: str\n" - " " - ) + # Only the model description is compared, not the parameter docstrings. + doc = models.Plant.__doc__.split(":ivar")[0].strip() + assert doc == "A plant in the garden. This model is used to represent a plant in the client SDK." def test_operation_doc_replaced(client: ClientDocClient): # @clientDoc in replace mode overrides the base @doc completely. - # The full docstring is compared, including the trailing indentation that closes the docstring. - assert client.documentation.harvest.__doc__ == ( - "Retrieves a plant from the garden by submitting its name.\n" - "\n" - " :param body: Is one of the following types: Plant, JSON, IO[bytes] Required.\n" - " :type body: ~specs.azure.clientgenerator.core.clientdoc.models.Plant or JSON or IO[bytes]\n" - " :return: Plant. The Plant is compatible with MutableMapping\n" - " :rtype: ~specs.azure.clientgenerator.core.clientdoc.models.Plant\n" - " :raises ~azure.core.exceptions.HttpResponseError:\n" - " " - ) + # Only the operation description is compared, not the parameter docstrings. + doc = client.documentation.harvest.__doc__.split(":param")[0].strip() + assert doc == "Retrieves a plant from the garden by submitting its name."