diff --git a/setup.py b/setup.py index 51d946e5c..33694506b 100644 --- a/setup.py +++ b/setup.py @@ -56,7 +56,6 @@ "grpcio", "flask", "freezegun", - "mock", # TODO(https://github.com/googleapis/google-auth-library-python/issues/1736): Remove `oauth2client` from testing requirements once an extra is added for `oauth2client` dependency. "oauth2client", *pyjwt_extra_require, diff --git a/system_tests/system_tests_sync/test_external_accounts.py b/system_tests/system_tests_sync/test_external_accounts.py index 837d0064b..eb15a011d 100644 --- a/system_tests/system_tests_sync/test_external_accounts.py +++ b/system_tests/system_tests_sync/test_external_accounts.py @@ -48,7 +48,7 @@ from http.server import HTTPServer from google.oauth2 import service_account import pytest -from mock import patch +from unittest.mock import patch # Populate values from the output of scripts/setup_external_accounts.sh. _AUDIENCE_OIDC = "//iam.googleapis.com/projects/79992041559/locations/global/workloadIdentityPools/pool-73wslmxn/providers/oidc-73wslmxn" diff --git a/system_tests/system_tests_sync/test_mtls_http.py b/system_tests/system_tests_sync/test_mtls_http.py index bcf2a59da..0955a15bf 100644 --- a/system_tests/system_tests_sync/test_mtls_http.py +++ b/system_tests/system_tests_sync/test_mtls_http.py @@ -13,10 +13,10 @@ # limitations under the License. import json -import mock import os import time from os import path +from unittest import mock import google.auth diff --git a/tests/compute_engine/test__metadata.py b/tests/compute_engine/test__metadata.py index 5bb85c264..5af4b2e3e 100644 --- a/tests/compute_engine/test__metadata.py +++ b/tests/compute_engine/test__metadata.py @@ -17,8 +17,8 @@ import importlib import json import os +from unittest import mock -import mock import pytest # type: ignore import requests diff --git a/tests/compute_engine/test_credentials.py b/tests/compute_engine/test_credentials.py index 9ef671425..2dec4814e 100644 --- a/tests/compute_engine/test_credentials.py +++ b/tests/compute_engine/test_credentials.py @@ -14,8 +14,8 @@ import base64 import datetime import os +from unittest import mock -import mock import pytest # type: ignore import responses # type: ignore diff --git a/tests/conftest.py b/tests/conftest.py index 8080ec3fa..fbce2575e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -14,8 +14,8 @@ import os import sys +from unittest import mock -import mock import pytest # type: ignore diff --git a/tests/crypt/test__python_rsa.py b/tests/crypt/test__python_rsa.py index 451c28341..ee14ed9f3 100644 --- a/tests/crypt/test__python_rsa.py +++ b/tests/crypt/test__python_rsa.py @@ -15,8 +15,8 @@ import io import json import os +from unittest import mock -import mock from pyasn1_modules import pem # type: ignore import pytest # type: ignore import rsa # type: ignore diff --git a/tests/oauth2/test__client.py b/tests/oauth2/test__client.py index b17ba542d..592c29e4f 100644 --- a/tests/oauth2/test__client.py +++ b/tests/oauth2/test__client.py @@ -17,8 +17,8 @@ import json import os import urllib +from unittest import mock -import mock import pytest # type: ignore from google.auth import _helpers diff --git a/tests/oauth2/test_challenges.py b/tests/oauth2/test_challenges.py index 8be39c6ef..532c7bf4e 100644 --- a/tests/oauth2/test_challenges.py +++ b/tests/oauth2/test_challenges.py @@ -17,8 +17,8 @@ import base64 import os import sys +from unitest import mock -import mock import pytest # type: ignore import pyu2f # type: ignore diff --git a/tests/oauth2/test_credentials.py b/tests/oauth2/test_credentials.py index 7d2a9b872..a30dbccee 100644 --- a/tests/oauth2/test_credentials.py +++ b/tests/oauth2/test_credentials.py @@ -17,8 +17,8 @@ import os import pickle import sys +from unittest import mock -import mock import pytest # type: ignore from google.auth import _helpers diff --git a/tests/oauth2/test_gdch_credentials.py b/tests/oauth2/test_gdch_credentials.py index 63075aba0..b889744e6 100644 --- a/tests/oauth2/test_gdch_credentials.py +++ b/tests/oauth2/test_gdch_credentials.py @@ -16,8 +16,8 @@ import datetime import json import os +from unittest import mock -import mock import pytest # type: ignore import requests diff --git a/tests/oauth2/test_id_token.py b/tests/oauth2/test_id_token.py index ff3d4b6d8..68b74f11b 100644 --- a/tests/oauth2/test_id_token.py +++ b/tests/oauth2/test_id_token.py @@ -14,8 +14,8 @@ import json import os +from unittest import mock -import mock import pytest # type: ignore from google.auth import environment_vars diff --git a/tests/oauth2/test_reauth.py b/tests/oauth2/test_reauth.py index a95367a2b..ef19e4c84 100644 --- a/tests/oauth2/test_reauth.py +++ b/tests/oauth2/test_reauth.py @@ -13,8 +13,8 @@ # limitations under the License. import copy +from unittest import mock -import mock import pytest # type: ignore from google.auth import exceptions diff --git a/tests/oauth2/test_service_account.py b/tests/oauth2/test_service_account.py index d23746fdf..788f52263 100644 --- a/tests/oauth2/test_service_account.py +++ b/tests/oauth2/test_service_account.py @@ -15,8 +15,8 @@ import datetime import json import os +from unittest import mock -import mock import pytest # type: ignore from google.auth import _helpers diff --git a/tests/oauth2/test_sts.py b/tests/oauth2/test_sts.py index 71856a623..dd82e8bfd 100644 --- a/tests/oauth2/test_sts.py +++ b/tests/oauth2/test_sts.py @@ -15,8 +15,8 @@ import http.client as http_client import json import urllib +from unittest import mock -import mock import pytest # type: ignore from google.auth import exceptions diff --git a/tests/oauth2/test_webauthn_handler.py b/tests/oauth2/test_webauthn_handler.py index 9fba266da..1dd75d6e1 100644 --- a/tests/oauth2/test_webauthn_handler.py +++ b/tests/oauth2/test_webauthn_handler.py @@ -1,7 +1,7 @@ import json import struct +from unittest import mock -import mock import pytest # type: ignore from google.auth import exceptions diff --git a/tests/oauth2/test_webauthn_handler_factory.py b/tests/oauth2/test_webauthn_handler_factory.py index 47890ce4b..1323de909 100644 --- a/tests/oauth2/test_webauthn_handler_factory.py +++ b/tests/oauth2/test_webauthn_handler_factory.py @@ -1,4 +1,5 @@ -import mock +from unittest import mock + import pytest # type: ignore from google.oauth2 import webauthn_handler diff --git a/tests/test__cloud_sdk.py b/tests/test__cloud_sdk.py index e45c65bd9..dd14bcebe 100644 --- a/tests/test__cloud_sdk.py +++ b/tests/test__cloud_sdk.py @@ -17,8 +17,8 @@ import os import subprocess import sys +from unittest import mock -import mock import pytest # type: ignore from google.auth import _cloud_sdk diff --git a/tests/test__default.py b/tests/test__default.py index 4bf21b422..7ff2ff943 100644 --- a/tests/test__default.py +++ b/tests/test__default.py @@ -14,9 +14,9 @@ import json import os +from unittest import mock import warnings -import mock import pytest # type: ignore from google.auth import _default diff --git a/tests/test__exponential_backoff.py b/tests/test__exponential_backoff.py index 358083eda..55cb918db 100644 --- a/tests/test__exponential_backoff.py +++ b/tests/test__exponential_backoff.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 # type: ignore from google.auth import _exponential_backoff diff --git a/tests/test__oauth2client.py b/tests/test__oauth2client.py index 0639be102..9936502e2 100644 --- a/tests/test__oauth2client.py +++ b/tests/test__oauth2client.py @@ -16,8 +16,8 @@ import importlib import os import sys +from unittest import mock -import mock import pytest # type: ignore try: diff --git a/tests/test__refresh_worker.py b/tests/test__refresh_worker.py index c25965d10..f4e797c75 100644 --- a/tests/test__refresh_worker.py +++ b/tests/test__refresh_worker.py @@ -16,8 +16,8 @@ import random import threading import time +from unittest import mock -import mock import pytest # type: ignore from google.auth import _refresh_worker, credentials, exceptions diff --git a/tests/test_app_engine.py b/tests/test_app_engine.py index ca085bd69..10b7bf371 100644 --- a/tests/test_app_engine.py +++ b/tests/test_app_engine.py @@ -13,8 +13,8 @@ # limitations under the License. import datetime +from unittest import mock -import mock import pytest # type: ignore from google.auth import app_engine diff --git a/tests/test_aws.py b/tests/test_aws.py index 5aa979c85..d9acf4b98 100644 --- a/tests/test_aws.py +++ b/tests/test_aws.py @@ -17,8 +17,8 @@ import json import os import urllib.parse +from unittest import mock -import mock import pytest # type: ignore from google.auth import _helpers, external_account diff --git a/tests/test_credentials.py b/tests/test_credentials.py index 1fb880096..750c92af2 100644 --- a/tests/test_credentials.py +++ b/tests/test_credentials.py @@ -14,8 +14,9 @@ import datetime import os +from unittest import mock + -import mock import pytest # type: ignore from google.auth import _helpers diff --git a/tests/test_downscoped.py b/tests/test_downscoped.py index 7c8f97018..2e490383d 100644 --- a/tests/test_downscoped.py +++ b/tests/test_downscoped.py @@ -16,8 +16,8 @@ import http.client as http_client import json import urllib +from unittest import mock -import mock import pytest # type: ignore from google.auth import _helpers diff --git a/tests/test_external_account.py b/tests/test_external_account.py index a56b54a43..59823c053 100644 --- a/tests/test_external_account.py +++ b/tests/test_external_account.py @@ -17,8 +17,8 @@ import json import os import urllib +from unittest import mock -import mock import pytest # type: ignore from google.auth import _helpers diff --git a/tests/test_external_account_authorized_user.py b/tests/test_external_account_authorized_user.py index 71bfaa39c..c6876a385 100644 --- a/tests/test_external_account_authorized_user.py +++ b/tests/test_external_account_authorized_user.py @@ -16,8 +16,8 @@ import http.client as http_client import json import os +from unittest import mock -import mock import pytest # type: ignore from google.auth import environment_vars diff --git a/tests/test_iam.py b/tests/test_iam.py index 01c2fa085..26a4c825a 100644 --- a/tests/test_iam.py +++ b/tests/test_iam.py @@ -16,8 +16,8 @@ import datetime import http.client as http_client import json +from unittest import mock -import mock import pytest # type: ignore from google.auth import _helpers diff --git a/tests/test_identity_pool.py b/tests/test_identity_pool.py index 548cd726d..6c44ba8ca 100644 --- a/tests/test_identity_pool.py +++ b/tests/test_identity_pool.py @@ -18,8 +18,8 @@ import json import os import urllib +from unittest import mock -import mock from OpenSSL import crypto import pytest # type: ignore diff --git a/tests/test_impersonated_credentials.py b/tests/test_impersonated_credentials.py index b4566576e..ad9257083 100644 --- a/tests/test_impersonated_credentials.py +++ b/tests/test_impersonated_credentials.py @@ -17,8 +17,8 @@ import http.client as http_client import json import os +from unittest import mock -import mock import pytest # type: ignore from google.auth import _helpers diff --git a/tests/test_jwt.py b/tests/test_jwt.py index 87cafab8b..9502bc32e 100644 --- a/tests/test_jwt.py +++ b/tests/test_jwt.py @@ -16,8 +16,8 @@ import datetime import json import os +from unittest import mock -import mock import pytest # type: ignore from google.auth import _helpers diff --git a/tests/test_metrics.py b/tests/test_metrics.py index ba9389267..c2e4014a0 100644 --- a/tests/test_metrics.py +++ b/tests/test_metrics.py @@ -13,8 +13,7 @@ # limitations under the License. import platform - -import mock +from unittest import mock from google.auth import metrics from google.auth import version diff --git a/tests/test_pluggable.py b/tests/test_pluggable.py index 5c1b4e660..ba1b780de 100644 --- a/tests/test_pluggable.py +++ b/tests/test_pluggable.py @@ -15,8 +15,8 @@ import json import os import subprocess +from unittest import mock -import mock import pytest # type: ignore from google.auth import exceptions diff --git a/tests/transport/aio/test_aiohttp.py b/tests/transport/aio/test_aiohttp.py index 632abff25..13f86ba34 100644 --- a/tests/transport/aio/test_aiohttp.py +++ b/tests/transport/aio/test_aiohttp.py @@ -13,9 +13,9 @@ # limitations under the License. import asyncio +from unittest.mock import AsyncMock, Mock, patch from aioresponses import aioresponses # type: ignore -from mock import AsyncMock, Mock, patch import pytest # type: ignore import pytest_asyncio # type: ignore diff --git a/tests/transport/aio/test_sessions.py b/tests/transport/aio/test_sessions.py index 742f863d0..d0cb21dda 100644 --- a/tests/transport/aio/test_sessions.py +++ b/tests/transport/aio/test_sessions.py @@ -14,9 +14,9 @@ import asyncio from typing import AsyncGenerator +from unittest.mock import Mock, patch from aioresponses import aioresponses # type: ignore -from mock import Mock, patch import pytest # type: ignore from google.auth.aio.credentials import AnonymousCredentials diff --git a/tests/transport/test__custom_tls_signer.py b/tests/transport/test__custom_tls_signer.py index 3a33c2c02..273a45869 100644 --- a/tests/transport/test__custom_tls_signer.py +++ b/tests/transport/test__custom_tls_signer.py @@ -14,8 +14,8 @@ import base64 import ctypes import os +from unittest import mock -import mock import pytest # type: ignore from requests.packages.urllib3.util.ssl_ import create_urllib3_context # type: ignore import urllib3.contrib.pyopenssl # type: ignore diff --git a/tests/transport/test__mtls_helper.py b/tests/transport/test__mtls_helper.py index 22d4f585f..7983e8200 100644 --- a/tests/transport/test__mtls_helper.py +++ b/tests/transport/test__mtls_helper.py @@ -14,8 +14,8 @@ import os import re +from unittes import mock -import mock from OpenSSL import crypto import pytest # type: ignore diff --git a/tests/transport/test_grpc.py b/tests/transport/test_grpc.py index ed3f3ee83..7ebd14758 100644 --- a/tests/transport/test_grpc.py +++ b/tests/transport/test_grpc.py @@ -15,8 +15,8 @@ import datetime import os import time +from unittest import mock -import mock import pytest # type: ignore from google.auth import _helpers diff --git a/tests/transport/test_mtls.py b/tests/transport/test_mtls.py index ef3053958..7abec0350 100644 --- a/tests/transport/test_mtls.py +++ b/tests/transport/test_mtls.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 # type: ignore from google.auth import exceptions diff --git a/tests/transport/test_requests.py b/tests/transport/test_requests.py index ccc937527..7d8d92c43 100644 --- a/tests/transport/test_requests.py +++ b/tests/transport/test_requests.py @@ -17,9 +17,9 @@ import http.client as http_client import os import sys +from unittest import mock import freezegun -import mock import OpenSSL import pytest # type: ignore import requests diff --git a/tests/transport/test_urllib3.py b/tests/transport/test_urllib3.py index 7872a7187..990953817 100644 --- a/tests/transport/test_urllib3.py +++ b/tests/transport/test_urllib3.py @@ -15,8 +15,8 @@ import http.client as http_client import os import sys +from unittest import mock -import mock import OpenSSL import pytest # type: ignore import urllib3 # type: ignore diff --git a/tests_async/conftest.py b/tests_async/conftest.py index f13dec0e4..55fd26463 100644 --- a/tests_async/conftest.py +++ b/tests_async/conftest.py @@ -14,8 +14,8 @@ import os import sys +from unittest import mock -import mock import pytest # type: ignore diff --git a/tests_async/oauth2/test__client_async.py b/tests_async/oauth2/test__client_async.py index d4b8d3427..f3cb9e551 100644 --- a/tests_async/oauth2/test__client_async.py +++ b/tests_async/oauth2/test__client_async.py @@ -16,8 +16,8 @@ import http.client as http_client import json import urllib +from unittest import mock -import mock import pytest # type: ignore from google.auth import _helpers diff --git a/tests_async/oauth2/test_credentials_async.py b/tests_async/oauth2/test_credentials_async.py index 4930a70a7..0a5d8ab1a 100644 --- a/tests_async/oauth2/test_credentials_async.py +++ b/tests_async/oauth2/test_credentials_async.py @@ -17,8 +17,8 @@ import os import pickle import sys +from unittest import mock -import mock import pytest # type: ignore from google.auth import _helpers diff --git a/tests_async/oauth2/test_id_token.py b/tests_async/oauth2/test_id_token.py index 9be086dca..51d85daf2 100644 --- a/tests_async/oauth2/test_id_token.py +++ b/tests_async/oauth2/test_id_token.py @@ -14,8 +14,8 @@ import json import os +from unittest import mock -import mock import pytest # type: ignore from google.auth import environment_vars diff --git a/tests_async/oauth2/test_reauth_async.py b/tests_async/oauth2/test_reauth_async.py index 40ca92717..4874a3728 100644 --- a/tests_async/oauth2/test_reauth_async.py +++ b/tests_async/oauth2/test_reauth_async.py @@ -13,8 +13,8 @@ # limitations under the License. import copy +from unittest import mock -import mock import pytest # type: ignore from google.auth import exceptions diff --git a/tests_async/oauth2/test_service_account_async.py b/tests_async/oauth2/test_service_account_async.py index 176992f77..5a9a89fca 100644 --- a/tests_async/oauth2/test_service_account_async.py +++ b/tests_async/oauth2/test_service_account_async.py @@ -13,8 +13,8 @@ # limitations under the License. import datetime +from unittest import mock -import mock import pytest # type: ignore from google.auth import _helpers diff --git a/tests_async/test__default_async.py b/tests_async/test__default_async.py index e1dbb1c09..a1268bdc0 100644 --- a/tests_async/test__default_async.py +++ b/tests_async/test__default_async.py @@ -14,8 +14,8 @@ import json import os +from unittest import mock -import mock import pytest # type: ignore from google.auth import _credentials_async as credentials diff --git a/tests_async/test_jwt_async.py b/tests_async/test_jwt_async.py index f24a0a99d..9d9eca4e2 100644 --- a/tests_async/test_jwt_async.py +++ b/tests_async/test_jwt_async.py @@ -14,8 +14,8 @@ import datetime import json +from unittest import mock -import mock import pytest # type: ignore from google.auth import _jwt_async as jwt_async diff --git a/tests_async/transport/test_aiohttp_requests.py b/tests_async/transport/test_aiohttp_requests.py index 1c825aaa6..fc8a572d5 100644 --- a/tests_async/transport/test_aiohttp_requests.py +++ b/tests_async/transport/test_aiohttp_requests.py @@ -14,7 +14,7 @@ import aiohttp # type: ignore from aioresponses import aioresponses, core # type: ignore -import mock +from unittest import mock import pytest # type: ignore from tests_async.transport import async_compliance