Skip to content

Commit dcf3026

Browse files
AleksMatcopybara-github
authored andcommitted
fix: Migrate usage of mock to unittest.mock
Python standard library contains `unittest.mock` since Python 3.3. Migrate usage of obsolete `mock` backport package to the stdlib module. PiperOrigin-RevId: 1019227484
1 parent 7b55775 commit dcf3026

11 files changed

Lines changed: 17 additions & 12 deletions

‎tests/unit/vertex_rag/test_rag_data_preview.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
# limitations under the License.
1414
#
1515
import importlib
16+
from unittest import mock
17+
from unittest.mock import patch
18+
1619
from google.api_core import operation as ga_operation
1720
from agentplatform.preview import rag
1821
from agentplatform.preview.rag.utils._gapic_utils import (
@@ -34,8 +37,6 @@
3437
ListRagMetadataResponse,
3538
)
3639
from google.cloud import aiplatform
37-
import mock
38-
from unittest.mock import patch
3940
import pytest
4041
import test_rag_constants_preview
4142

‎tests/unit/vertex_rag/test_rag_retrieval.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
"""Tests for vertex_rag.retrieval."""
1616

1717
import importlib
18+
from unittest import mock
1819

1920
from google.cloud import aiplatform
2021
from agentplatform import rag
2122
from google.cloud.aiplatform_v1 import VertexRagServiceAsyncClient
2223
from google.cloud.aiplatform_v1 import VertexRagServiceClient
2324
import test_rag_constants as tc
24-
import mock
2525
import pytest
2626

2727

‎tests/unit/vertex_rag/test_rag_retrieval_preview.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
"""Tests for vertex_rag.retrieval_preview."""
1616

1717
import importlib
18+
from unittest import mock
19+
1820
from google.cloud import aiplatform
1921
from google.cloud.aiplatform_v1beta1 import VertexRagServiceAsyncClient
2022
from google.cloud.aiplatform_v1beta1 import VertexRagServiceClient
2123
import test_rag_constants_preview
2224
from agentplatform.preview import rag
23-
import mock
2425
import pytest
2526

2627
tc = test_rag_constants_preview

‎tests/unit/vertex_ray/conftest.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
# limitations under the License.
1414
#
1515

16+
from unittest import mock
17+
1618
from google import auth
1719
from google.api_core import exceptions
1820
from google.api_core import operation as ga_operation
@@ -32,7 +34,6 @@
3234
DeletePersistentResourceRequest,
3335
)
3436
import test_constants as tc
35-
import mock
3637
import pytest
3738

3839

‎tests/unit/vertex_ray/test_bigquery.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#
1717

1818
import importlib
19+
from unittest import mock
1920

2021
from google.api_core import exceptions
2122
from google.api_core import operation
@@ -29,7 +30,6 @@
2930
import test_constants as tc
3031
from google.cloud.bigquery import job
3132
from google.cloud.bigquery_storage_v1.types import stream as gcbqs_stream
32-
import mock
3333
import pytest
3434
import pyarrow as pa
3535
import ray

‎tests/unit/vertex_ray/test_cluster_init.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import copy
1616
import importlib
1717
import re
18+
from unittest import mock
1819

1920
from google.api_core import operation as ga_operation
2021
from google.cloud import aiplatform
@@ -28,7 +29,6 @@
2829
)
2930
from google.cloud.aiplatform_v1beta1.types import persistent_resource_service
3031
import test_constants as tc
31-
import mock
3232
import pytest
3333

3434
from google.protobuf import field_mask_pb2 # type: ignore

‎tests/unit/vertex_ray/test_dashboard_sdk.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
# limitations under the License.
1414
#
1515
import importlib
16+
from unittest import mock
1617

1718
from google.cloud import aiplatform
1819
from google.cloud.aiplatform import vertex_ray
1920
import test_constants as tc
20-
import mock
2121
import pytest
2222
from ray.dashboard.modules import dashboard_sdk as oss_dashboard_sdk
2323

‎tests/unit/vertex_ray/test_ray_prediction.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import importlib
2020
import pickle
2121
import tempfile
22+
from unittest import mock
2223

2324
from google.cloud import aiplatform
2425
from google.cloud.aiplatform.vertex_ray.predict import (
@@ -37,7 +38,6 @@
3738
import test_constants as tc
3839
import test_prediction_utils
3940

40-
import mock
4141
import numpy as np
4242
import pytest
4343
import ray

‎tests/unit/vertex_ray/test_vertex_ray_client.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
# limitations under the License.
1414
#
1515
import importlib
16+
from unittest import mock
1617

1718
from google.cloud import aiplatform
1819
from google.cloud.aiplatform import vertex_ray
1920
import test_constants as tc
20-
import mock
2121
import pytest
2222
import ray
2323

‎tests/unit/vertexai/test_caching.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
import datetime
2121
import io
2222
import json
23-
import mock
23+
from unittest import mock
24+
2425
import pytest
2526
from vertexai.caching import CachedContent
2627
from google.cloud.aiplatform import initializer

0 commit comments

Comments
 (0)