From 6f6815c89e7160e7388ee8e855e6642f7fe9803a97ea2d18a547d51cf64fd6b6 Mon Sep 17 00:00:00 2001 From: Steve Kowalik Date: Tue, 29 Oct 2024 04:42:53 +0000 Subject: [PATCH] - Resurrect python-google-api-core-no-mock.patch and refresh it, it is still required until 2.22.0. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-google-api-core?expand=0&rev=77 --- python-google-api-core-no-mock.patch | 385 +++++++++++++++++++++++++++ python-google-api-core.changes | 6 + python-google-api-core.spec | 2 + 3 files changed, 393 insertions(+) create mode 100644 python-google-api-core-no-mock.patch diff --git a/python-google-api-core-no-mock.patch b/python-google-api-core-no-mock.patch new file mode 100644 index 0000000..c43bae2 --- /dev/null +++ b/python-google-api-core-no-mock.patch @@ -0,0 +1,385 @@ +From 5f28e210306de47ff5a9fa3b4bf48ac6ceb13e85 Mon Sep 17 00:00:00 2001 +From: Steve Kowalik +Date: Wed, 2 Oct 2024 13:50:33 +1000 +Subject: [PATCH] test: Switch to unittest.mock from mock + +Now that the minimum supported version of Python is 3.7, we can stop +using the external mock requirement, and import it from unittest. I have +also attempted to keep imports ordered. + +Fixes #377 +--- + noxfile.py | 2 -- + tests/asyncio/future/test_async_future.py | 2 +- + tests/asyncio/gapic/test_method_async.py | 2 +- + tests/asyncio/operations_v1/test_operations_async_client.py | 3 ++- + tests/asyncio/retry/test_retry_streaming_async.py | 4 ++-- + tests/asyncio/retry/test_retry_unary_async.py | 2 +- + tests/asyncio/test_grpc_helpers_async.py | 3 ++- + tests/asyncio/test_operation_async.py | 3 ++- + tests/asyncio/test_page_iterator_async.py | 2 +- + tests/asyncio/test_rest_streaming_async.py | 6 +++--- + tests/unit/future/test__helpers.py | 2 +- + tests/unit/future/test_polling.py | 2 +- + tests/unit/gapic/test_method.py | 2 +- + tests/unit/operations_v1/test_operations_rest_client.py | 2 +- + tests/unit/retry/test_retry_base.py | 2 +- + tests/unit/retry/test_retry_streaming.py | 2 +- + tests/unit/retry/test_retry_unary.py | 2 +- + tests/unit/test_bidi.py | 2 +- + tests/unit/test_exceptions.py | 2 +- + tests/unit/test_extended_operation.py | 2 +- + tests/unit/test_grpc_helpers.py | 3 ++- + tests/unit/test_operation.py | 3 ++- + tests/unit/test_page_iterator.py | 2 +- + tests/unit/test_path_template.py | 2 +- + tests/unit/test_timeout.py | 3 +-- + 25 files changed, 32 insertions(+), 30 deletions(-) + +Index: google_api_core-2.21.0/tests/asyncio/future/test_async_future.py +=================================================================== +--- google_api_core-2.21.0.orig/tests/asyncio/future/test_async_future.py ++++ google_api_core-2.21.0/tests/asyncio/future/test_async_future.py +@@ -13,8 +13,8 @@ + # limitations under the License. + + import asyncio ++from unittest import mock + +-import mock + import pytest + + from google.api_core import exceptions +Index: google_api_core-2.21.0/tests/asyncio/gapic/test_method_async.py +=================================================================== +--- google_api_core-2.21.0.orig/tests/asyncio/gapic/test_method_async.py ++++ google_api_core-2.21.0/tests/asyncio/gapic/test_method_async.py +@@ -13,8 +13,8 @@ + # limitations under the License. + + import datetime ++from unittest import mock + +-import mock + import pytest + + try: +Index: google_api_core-2.21.0/tests/asyncio/operations_v1/test_operations_async_client.py +=================================================================== +--- google_api_core-2.21.0.orig/tests/asyncio/operations_v1/test_operations_async_client.py ++++ google_api_core-2.21.0/tests/asyncio/operations_v1/test_operations_async_client.py +@@ -12,7 +12,8 @@ + # See the License for the specific language governing permissions and + # limitations under the License. + +-import mock ++from unittest import mock ++ + import pytest + + try: +Index: google_api_core-2.21.0/tests/asyncio/retry/test_retry_streaming_async.py +=================================================================== +--- google_api_core-2.21.0.orig/tests/asyncio/retry/test_retry_streaming_async.py ++++ google_api_core-2.21.0/tests/asyncio/retry/test_retry_streaming_async.py +@@ -12,11 +12,11 @@ + # See the License for the specific language governing permissions and + # limitations under the License. + ++import asyncio + import datetime + import re +-import asyncio ++from unittest import mock + +-import mock + import pytest + + from google.api_core import exceptions +Index: google_api_core-2.21.0/tests/asyncio/retry/test_retry_unary_async.py +=================================================================== +--- google_api_core-2.21.0.orig/tests/asyncio/retry/test_retry_unary_async.py ++++ google_api_core-2.21.0/tests/asyncio/retry/test_retry_unary_async.py +@@ -14,8 +14,8 @@ + + import datetime + import re ++from unittest import mock + +-import mock + import pytest + + from google.api_core import exceptions +Index: google_api_core-2.21.0/tests/asyncio/test_grpc_helpers_async.py +=================================================================== +--- google_api_core-2.21.0.orig/tests/asyncio/test_grpc_helpers_async.py ++++ google_api_core-2.21.0/tests/asyncio/test_grpc_helpers_async.py +@@ -12,7 +12,8 @@ + # See the License for the specific language governing permissions and + # limitations under the License. + +-import mock ++from unittest import mock ++ + import pytest # noqa: I202 + + try: +Index: google_api_core-2.21.0/tests/asyncio/test_operation_async.py +=================================================================== +--- google_api_core-2.21.0.orig/tests/asyncio/test_operation_async.py ++++ google_api_core-2.21.0/tests/asyncio/test_operation_async.py +@@ -13,7 +13,8 @@ + # limitations under the License. + + +-import mock ++from unittest import mock ++ + import pytest + + try: +Index: google_api_core-2.21.0/tests/asyncio/test_page_iterator_async.py +=================================================================== +--- google_api_core-2.21.0.orig/tests/asyncio/test_page_iterator_async.py ++++ google_api_core-2.21.0/tests/asyncio/test_page_iterator_async.py +@@ -13,8 +13,8 @@ + # limitations under the License. + + import inspect ++from unittest import mock + +-import mock + import pytest + + from google.api_core import page_iterator_async +Index: google_api_core-2.21.0/tests/asyncio/test_rest_streaming_async.py +=================================================================== +--- google_api_core-2.21.0.orig/tests/asyncio/test_rest_streaming_async.py ++++ google_api_core-2.21.0/tests/asyncio/test_rest_streaming_async.py +@@ -15,14 +15,14 @@ + # TODO: set random.seed explicitly in each test function. + # See related issue: https://github.com/googleapis/python-api-core/issues/689. + +-import pytest # noqa: I202 +-import mock +- + import datetime + import logging + import random + import time + from typing import List, AsyncIterator ++from unittest import mock ++ ++import pytest # noqa: I202 + + import proto + +Index: google_api_core-2.21.0/tests/unit/future/test__helpers.py +=================================================================== +--- google_api_core-2.21.0.orig/tests/unit/future/test__helpers.py ++++ google_api_core-2.21.0/tests/unit/future/test__helpers.py +@@ -12,7 +12,7 @@ + # See the License for the specific language governing permissions and + # limitations under the License. + +-import mock ++from unittest import mock + + from google.api_core.future import _helpers + +Index: google_api_core-2.21.0/tests/unit/future/test_polling.py +=================================================================== +--- google_api_core-2.21.0.orig/tests/unit/future/test_polling.py ++++ google_api_core-2.21.0/tests/unit/future/test_polling.py +@@ -15,8 +15,8 @@ + import concurrent.futures + import threading + import time ++from unittest import mock + +-import mock + import pytest + + from google.api_core import exceptions, retry +Index: google_api_core-2.21.0/tests/unit/gapic/test_method.py +=================================================================== +--- google_api_core-2.21.0.orig/tests/unit/gapic/test_method.py ++++ google_api_core-2.21.0/tests/unit/gapic/test_method.py +@@ -13,8 +13,8 @@ + # limitations under the License. + + import datetime ++from unittest import mock + +-import mock + import pytest + + try: +Index: google_api_core-2.21.0/tests/unit/operations_v1/test_operations_rest_client.py +=================================================================== +--- google_api_core-2.21.0.orig/tests/unit/operations_v1/test_operations_rest_client.py ++++ google_api_core-2.21.0/tests/unit/operations_v1/test_operations_rest_client.py +@@ -14,8 +14,8 @@ + # limitations under the License. + # + import os ++from unittest import mock + +-import mock + import pytest + from typing import Any, List + +Index: google_api_core-2.21.0/tests/unit/retry/test_retry_base.py +=================================================================== +--- google_api_core-2.21.0.orig/tests/unit/retry/test_retry_base.py ++++ google_api_core-2.21.0/tests/unit/retry/test_retry_base.py +@@ -14,8 +14,8 @@ + + import itertools + import re ++from unittest import mock + +-import mock + import pytest + import requests.exceptions + +Index: google_api_core-2.21.0/tests/unit/retry/test_retry_streaming.py +=================================================================== +--- google_api_core-2.21.0.orig/tests/unit/retry/test_retry_streaming.py ++++ google_api_core-2.21.0/tests/unit/retry/test_retry_streaming.py +@@ -13,8 +13,8 @@ + # limitations under the License. + + import re ++from unittest import mock + +-import mock + import pytest + + from google.api_core import exceptions +Index: google_api_core-2.21.0/tests/unit/retry/test_retry_unary.py +=================================================================== +--- google_api_core-2.21.0.orig/tests/unit/retry/test_retry_unary.py ++++ google_api_core-2.21.0/tests/unit/retry/test_retry_unary.py +@@ -14,8 +14,8 @@ + + import datetime + import re ++from unittest import mock + +-import mock + import pytest + + from google.api_core import exceptions +Index: google_api_core-2.21.0/tests/unit/test_bidi.py +=================================================================== +--- google_api_core-2.21.0.orig/tests/unit/test_bidi.py ++++ google_api_core-2.21.0/tests/unit/test_bidi.py +@@ -16,8 +16,8 @@ import datetime + import logging + import queue + import threading ++from unittest import mock + +-import mock + import pytest + + try: +Index: google_api_core-2.21.0/tests/unit/test_exceptions.py +=================================================================== +--- google_api_core-2.21.0.orig/tests/unit/test_exceptions.py ++++ google_api_core-2.21.0/tests/unit/test_exceptions.py +@@ -14,8 +14,8 @@ + + import http.client + import json ++from unittest import mock + +-import mock + import pytest + import requests + +Index: google_api_core-2.21.0/tests/unit/test_extended_operation.py +=================================================================== +--- google_api_core-2.21.0.orig/tests/unit/test_extended_operation.py ++++ google_api_core-2.21.0/tests/unit/test_extended_operation.py +@@ -15,8 +15,8 @@ + import dataclasses + import enum + import typing ++from unittest import mock + +-import mock + import pytest + + from google.api_core import exceptions +Index: google_api_core-2.21.0/tests/unit/test_grpc_helpers.py +=================================================================== +--- google_api_core-2.21.0.orig/tests/unit/test_grpc_helpers.py ++++ google_api_core-2.21.0/tests/unit/test_grpc_helpers.py +@@ -12,7 +12,8 @@ + # See the License for the specific language governing permissions and + # limitations under the License. + +-import mock ++from unittest import mock ++ + import pytest + + try: +Index: google_api_core-2.21.0/tests/unit/test_operation.py +=================================================================== +--- google_api_core-2.21.0.orig/tests/unit/test_operation.py ++++ google_api_core-2.21.0/tests/unit/test_operation.py +@@ -13,7 +13,8 @@ + # limitations under the License. + + +-import mock ++from unittest import mock ++ + import pytest + + try: +Index: google_api_core-2.21.0/tests/unit/test_page_iterator.py +=================================================================== +--- google_api_core-2.21.0.orig/tests/unit/test_page_iterator.py ++++ google_api_core-2.21.0/tests/unit/test_page_iterator.py +@@ -14,8 +14,8 @@ + + import math + import types ++from unittest import mock + +-import mock + import pytest + + from google.api_core import page_iterator +Index: google_api_core-2.21.0/tests/unit/test_path_template.py +=================================================================== +--- google_api_core-2.21.0.orig/tests/unit/test_path_template.py ++++ google_api_core-2.21.0/tests/unit/test_path_template.py +@@ -13,8 +13,8 @@ + # limitations under the License. + + from __future__ import unicode_literals ++from unittest import mock + +-import mock + import pytest + + from google.api import auth_pb2 +Index: google_api_core-2.21.0/tests/unit/test_timeout.py +=================================================================== +--- google_api_core-2.21.0.orig/tests/unit/test_timeout.py ++++ google_api_core-2.21.0/tests/unit/test_timeout.py +@@ -14,8 +14,7 @@ + + import datetime + import itertools +- +-import mock ++from unittest import mock + + from google.api_core import timeout as timeouts + diff --git a/python-google-api-core.changes b/python-google-api-core.changes index cfd439e..973e292 100644 --- a/python-google-api-core.changes +++ b/python-google-api-core.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Tue Oct 29 04:42:29 UTC 2024 - Steve Kowalik + +- Resurrect python-google-api-core-no-mock.patch and refresh it, it is + still required until 2.22.0. + ------------------------------------------------------------------- Mon Oct 28 12:59:16 UTC 2024 - John Paul Adrian Glaubitz diff --git a/python-google-api-core.spec b/python-google-api-core.spec index a6533dd..1f1f281 100644 --- a/python-google-api-core.spec +++ b/python-google-api-core.spec @@ -32,6 +32,8 @@ Summary: Google API client core library License: Apache-2.0 URL: https://github.com/googleapis/python-api-core Source: https://files.pythonhosted.org/packages/source/g/google_api_core/google_api_core-%{version}.tar.gz +# PATCH-FIX-UPSTREAM Based on gh#googleapis/python-api-core#713 +Patch0: python-google-api-core-no-mock.patch # Needed for python_sitelib/google BuildRequires: %{python_module googleapis-common-protos >= 1.56.2} BuildRequires: %{python_module pip}