From 215217ea8b2375aa6e5e65fbc96b591a15a695d6 Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Sat, 18 Apr 2020 11:53:42 -0500 Subject: [PATCH] Use unittest.mock instead of third party mock Now that we no longer support py27, we can use the standard library unittest.mock module instead of the third party mock lib. Change-Id: Idc319f3f8a3ddd57cba91e4cefc66dbb18d5cc22 Signed-off-by: Sean McGinnis --- doc/requirements.txt | 1 - keystonemiddleware/tests/unit/audit/test_audit_middleware.py | 2 +- .../tests/unit/audit/test_audit_oslo_messaging.py | 2 +- keystonemiddleware/tests/unit/audit/test_logging_notifier.py | 3 ++- .../tests/unit/auth_token/test_auth_token_middleware.py | 2 +- .../tests/unit/auth_token/test_base_middleware.py | 2 +- keystonemiddleware/tests/unit/auth_token/test_config.py | 2 +- .../tests/unit/auth_token/test_connection_pool.py | 2 +- keystonemiddleware/tests/unit/test_ec2_token_middleware.py | 3 ++- keystonemiddleware/tests/unit/test_s3_token_middleware.py | 3 ++- keystonemiddleware/tests/unit/utils.py | 2 +- test-requirements.txt | 1 - 12 files changed, 13 insertions(+), 12 deletions(-) diff --git a/doc/requirements.txt b/doc/requirements.txt index f89d55aa..9aad4bbc 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -13,7 +13,6 @@ sphinxcontrib-apidoc>=0.2.0 # BSD sphinxcontrib-svg2pdfconverter>=0.1.0 # BSD # For autodoc builds -mock>=2.0.0 # BSD oslotest>=3.2.0 # Apache-2.0 requests-mock>=1.2.0 # Apache-2.0 testresources>=2.0.0 # Apache-2.0/BSD diff --git a/keystonemiddleware/tests/unit/audit/test_audit_middleware.py b/keystonemiddleware/tests/unit/audit/test_audit_middleware.py index baf10bf8..c302129b 100644 --- a/keystonemiddleware/tests/unit/audit/test_audit_middleware.py +++ b/keystonemiddleware/tests/unit/audit/test_audit_middleware.py @@ -11,10 +11,10 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock import uuid import fixtures -import mock import webob from keystonemiddleware.tests.unit.audit import base diff --git a/keystonemiddleware/tests/unit/audit/test_audit_oslo_messaging.py b/keystonemiddleware/tests/unit/audit/test_audit_oslo_messaging.py index 6dcd837e..fd7f9506 100644 --- a/keystonemiddleware/tests/unit/audit/test_audit_oslo_messaging.py +++ b/keystonemiddleware/tests/unit/audit/test_audit_oslo_messaging.py @@ -10,7 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from keystonemiddleware import audit from keystonemiddleware.tests.unit.audit import base diff --git a/keystonemiddleware/tests/unit/audit/test_logging_notifier.py b/keystonemiddleware/tests/unit/audit/test_logging_notifier.py index 08018616..f734061f 100644 --- a/keystonemiddleware/tests/unit/audit/test_logging_notifier.py +++ b/keystonemiddleware/tests/unit/audit/test_logging_notifier.py @@ -10,8 +10,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import fixtures -import mock from keystonemiddleware.tests.unit.audit import base diff --git a/keystonemiddleware/tests/unit/auth_token/test_auth_token_middleware.py b/keystonemiddleware/tests/unit/auth_token/test_auth_token_middleware.py index 98015406..64586a90 100644 --- a/keystonemiddleware/tests/unit/auth_token/test_auth_token_middleware.py +++ b/keystonemiddleware/tests/unit/auth_token/test_auth_token_middleware.py @@ -15,6 +15,7 @@ import datetime import os import time +from unittest import mock import uuid import fixtures @@ -22,7 +23,6 @@ from keystoneauth1 import exceptions as ksa_exceptions from keystoneauth1 import fixture from keystoneauth1 import loading from keystoneauth1 import session -import mock import oslo_cache from oslo_log import log as logging from oslo_serialization import jsonutils diff --git a/keystonemiddleware/tests/unit/auth_token/test_base_middleware.py b/keystonemiddleware/tests/unit/auth_token/test_base_middleware.py index a3c06bc7..f30a2d0f 100644 --- a/keystonemiddleware/tests/unit/auth_token/test_base_middleware.py +++ b/keystonemiddleware/tests/unit/auth_token/test_base_middleware.py @@ -11,10 +11,10 @@ # under the License. import datetime +from unittest import mock import uuid from keystoneauth1 import fixture -import mock import testtools import webob diff --git a/keystonemiddleware/tests/unit/auth_token/test_config.py b/keystonemiddleware/tests/unit/auth_token/test_config.py index 6a253a11..6bc7c854 100644 --- a/keystonemiddleware/tests/unit/auth_token/test_config.py +++ b/keystonemiddleware/tests/unit/auth_token/test_config.py @@ -10,9 +10,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock import uuid -import mock from oslo_config import cfg from oslotest import createfile diff --git a/keystonemiddleware/tests/unit/auth_token/test_connection_pool.py b/keystonemiddleware/tests/unit/auth_token/test_connection_pool.py index 699b5b5a..254c0604 100644 --- a/keystonemiddleware/tests/unit/auth_token/test_connection_pool.py +++ b/keystonemiddleware/tests/unit/auth_token/test_connection_pool.py @@ -11,8 +11,8 @@ # under the License. import time +from unittest import mock -import mock from oslo_cache import _memcache_pool from six.moves import queue import testtools diff --git a/keystonemiddleware/tests/unit/test_ec2_token_middleware.py b/keystonemiddleware/tests/unit/test_ec2_token_middleware.py index 5cd69ff0..be6a0d16 100644 --- a/keystonemiddleware/tests/unit/test_ec2_token_middleware.py +++ b/keystonemiddleware/tests/unit/test_ec2_token_middleware.py @@ -12,7 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from oslo_serialization import jsonutils import requests import six diff --git a/keystonemiddleware/tests/unit/test_s3_token_middleware.py b/keystonemiddleware/tests/unit/test_s3_token_middleware.py index f9857a9f..7e660a2a 100644 --- a/keystonemiddleware/tests/unit/test_s3_token_middleware.py +++ b/keystonemiddleware/tests/unit/test_s3_token_middleware.py @@ -12,8 +12,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import fixtures -import mock from oslo_serialization import jsonutils import requests from requests_mock.contrib import fixture as rm_fixture diff --git a/keystonemiddleware/tests/unit/utils.py b/keystonemiddleware/tests/unit/utils.py index 8b0944fa..63a329b8 100644 --- a/keystonemiddleware/tests/unit/utils.py +++ b/keystonemiddleware/tests/unit/utils.py @@ -12,11 +12,11 @@ import sys import time +from unittest import mock import uuid import warnings import fixtures -import mock from oslo_log import log as logging import oslotest.base as oslotest import requests diff --git a/test-requirements.txt b/test-requirements.txt index 3ab58aa1..c6d68d61 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -8,7 +8,6 @@ flake8-docstrings==0.2.1.post1 # MIT coverage!=4.4,>=4.0 # Apache-2.0 cryptography>=2.1 # BSD/Apache-2.0 fixtures>=3.0.0 # Apache-2.0/BSD -mock>=2.0.0 # BSD oslotest>=3.2.0 # Apache-2.0 requests-mock>=1.2.0 # Apache-2.0 stevedore>=1.20.0 # Apache-2.0