Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit 3d4f590

Browse files
committed
add missing import for mock
1 parent 9037998 commit 3d4f590

3 files changed

Lines changed: 54 additions & 3 deletions

File tree

gapic/templates/%namespace/%name_%version/%sub/_compat/legacy_helpers.py.j2

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1+
{% extends '_base.py.j2' %}
2+
3+
{% block content %}
14

25
import os
36

7+
# try/except added for compatibility with python < 3.8
8+
try:
9+
from unittest import mock
10+
except ImportError: # pragma: NO COVER
11+
import mock
12+
413
from google.auth.exceptions import MutualTLSChannelError # type: ignore
514

615
def _read_environment_variables():
@@ -23,4 +32,6 @@ def _read_environment_variables():
2332
raise ValueError("Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`")
2433
if use_mtls_endpoint not in ("auto", "never", "always"):
2534
raise MutualTLSChannelError("Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`")
26-
return use_client_cert == "true", use_mtls_endpoint, universe_domain_env
35+
return use_client_cert == "true", use_mtls_endpoint, universe_domain_env
36+
37+
{% endblock %}

tests/integration/goldens/asset/google/cloud/asset_v1/_compat/legacy_helpers.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
1-
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2025 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
216
import os
317

18+
# try/except added for compatibility with python < 3.8
19+
try:
20+
from unittest import mock
21+
except ImportError: # pragma: NO COVER
22+
import mock
23+
424
from google.auth.exceptions import MutualTLSChannelError # type: ignore
525

626
def _read_environment_variables():

tests/integration/goldens/redis/google/cloud/redis_v1/_compat/legacy_helpers.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
1-
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2025 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
216
import os
317

18+
# try/except added for compatibility with python < 3.8
19+
try:
20+
from unittest import mock
21+
except ImportError: # pragma: NO COVER
22+
import mock
23+
424
from google.auth.exceptions import MutualTLSChannelError # type: ignore
525

626
def _read_environment_variables():

0 commit comments

Comments
 (0)