* Memory leak in bidi classes (#770) * Resolve the issue where rpc timeout of 0 is used when timeout expires (#776) * Add warnings regarding consuming externally sourced credentials (#783) OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-google-api-core?expand=0&rev=83
386 lines
13 KiB
Diff
386 lines
13 KiB
Diff
From 5f28e210306de47ff5a9fa3b4bf48ac6ceb13e85 Mon Sep 17 00:00:00 2001
|
|
From: Steve Kowalik <steven@wedontsleep.org>
|
|
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
|
|
|