From 1fd9283eb177a92d273ece47fa95ec347b90996a Mon Sep 17 00:00:00 2001 From: Sakthivel Subramanian Date: Thu, 6 Aug 2026 07:49:58 +0000 Subject: [PATCH] test(spanner): initialize _client_info with ClientInfo instance in mock client Replace CrossSync.Mock() and mock.Mock() with gapic_v1.client_info.ClientInfo() in _Client test helper mocks in test_database.py and _async/test_database.py. In google-api-core (PR #17616), GapicCallable pre-extracts the metrics header from metadata at initialization time via client_info.to_grpc_metadata(). Using an AsyncMock or Mock for client_info caused to_grpc_metadata() to return a coroutine or Mock object instead of the expected (key, value) metadata tuple, leading to a TypeError in core_deps_from_source sessions. --- .../google-cloud-spanner/tests/unit/_async/test_database.py | 2 +- packages/google-cloud-spanner/tests/unit/test_database.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/google-cloud-spanner/tests/unit/_async/test_database.py b/packages/google-cloud-spanner/tests/unit/_async/test_database.py index bfb96e0aa091..1d5c57599693 100644 --- a/packages/google-cloud-spanner/tests/unit/_async/test_database.py +++ b/packages/google-cloud-spanner/tests/unit/_async/test_database.py @@ -4124,7 +4124,7 @@ def __init__( self._endpoint_cache = {} self.database_admin_api = _make_database_admin_api() self.instance_admin_api = _make_instance_api() - self._client_info = CrossSync.Mock() + self._client_info = gapic_v1.client_info.ClientInfo() self._client_options = CrossSync.Mock() self._client_options.universe_domain = "googleapis.com" self._client_options.api_key = None diff --git a/packages/google-cloud-spanner/tests/unit/test_database.py b/packages/google-cloud-spanner/tests/unit/test_database.py index 106321cc68e6..21c382b45438 100644 --- a/packages/google-cloud-spanner/tests/unit/test_database.py +++ b/packages/google-cloud-spanner/tests/unit/test_database.py @@ -3557,7 +3557,7 @@ def __init__( self._endpoint_cache = {} self.database_admin_api = _make_database_admin_api() self.instance_admin_api = _make_instance_api() - self._client_info = mock.Mock() + self._client_info = gapic_v1.client_info.ClientInfo() self._client_options = mock.Mock() self._client_options.universe_domain = "googleapis.com" self._client_options.api_key = None