From 78af6ca242949f10b17793707fde95d5ae710ea2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Beraud?= Date: Tue, 9 Jun 2020 12:06:07 +0200 Subject: [PATCH] Use unittest.mock instead of mock The mock third party library was needed for mock support in py2 runtimes. Since we now only support py36 and later, we can use the standard lib unittest.mock module instead. Also osc-lib must be cap to 2.1.0 to fix the lower-constraints job issue and stop to use mock on osc-lib [1] too. [1] https://github.com/openstack/osc-lib/commit/2d98486d0619c0729f3962d9c0db50d9ef156a50 Change-Id: I95e8d9564cda2e6a06a3f40b0de6991acb07dd4c --- lower-constraints.txt | 3 +-- requirements.txt | 2 +- test-requirements.txt | 1 - tests/unit/auth/test_keystone.py | 2 +- tests/unit/cli/fakes.py | 3 ++- tests/unit/common/test_http.py | 2 +- tests/unit/queues/v1/test_client.py | 2 +- tests/unit/queues/v1/test_core.py | 2 +- tests/unit/queues/v1/test_message.py | 2 +- tests/unit/queues/v2/test_client.py | 2 +- tests/unit/queues/v2/test_message.py | 2 +- tests/unit/transport/test_http.py | 3 ++- tests/unit/transport/test_ws.py | 2 +- zaqarclient/tests/queues/base.py | 3 ++- zaqarclient/tests/queues/claims.py | 2 +- zaqarclient/tests/queues/flavor.py | 2 +- zaqarclient/tests/queues/health.py | 2 +- zaqarclient/tests/queues/messages.py | 2 +- zaqarclient/tests/queues/pool.py | 2 +- zaqarclient/tests/queues/queues.py | 2 +- zaqarclient/tests/queues/subscriptions.py | 2 +- 21 files changed, 23 insertions(+), 22 deletions(-) diff --git a/lower-constraints.txt b/lower-constraints.txt index c12f3c5..e283d60 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -27,7 +27,6 @@ keystoneauth1==3.4.0 linecache2==1.0.0 MarkupSafe==1.0 mccabe==0.2.1 -mock==2.0.0 monotonic==0.6 msgpack-python==0.4.0 munch==2.1.0 @@ -36,7 +35,7 @@ netifaces==0.10.4 openstacksdk==0.11.2 os-client-config==1.28.0 os-service-types==1.2.0 -osc-lib==1.8.0 +osc-lib==2.1.0 oslo.config==5.2.0 oslo.context==2.19.2 oslo.i18n==3.15.3 diff --git a/requirements.txt b/requirements.txt index 1f185a4..d0adfc8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,4 +13,4 @@ oslo.log>=3.36.0 # Apache-2.0 oslo.utils>=3.33.0 # Apache-2.0 keystoneauth1>=3.4.0 # Apache-2.0 -osc-lib>=1.8.0 # Apache-2.0 +osc-lib>=2.1.0 # Apache-2.0 diff --git a/test-requirements.txt b/test-requirements.txt index 879bf76..8f37990 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -6,7 +6,6 @@ hacking>=3.0,<3.1.0 # Apache-2.0 # Unit testing fixtures>=3.0.0 # Apache-2.0/BSD -mock>=2.0.0 # BSD testtools>=2.2.0 # MIT # Test runner diff --git a/tests/unit/auth/test_keystone.py b/tests/unit/auth/test_keystone.py index bd76a54..2a208d1 100644 --- a/tests/unit/auth/test_keystone.py +++ b/tests/unit/auth/test_keystone.py @@ -14,7 +14,7 @@ # limitations under the License. -import mock +from unittest import mock from keystoneauth1 import session diff --git a/tests/unit/cli/fakes.py b/tests/unit/cli/fakes.py index 73931b9..d6ed5bd 100644 --- a/tests/unit/cli/fakes.py +++ b/tests/unit/cli/fakes.py @@ -14,7 +14,8 @@ # limitations under the License. -import mock +from unittest import mock + from osc_lib.tests import utils diff --git a/tests/unit/common/test_http.py b/tests/unit/common/test_http.py index 8683336..9a62e7c 100644 --- a/tests/unit/common/test_http.py +++ b/tests/unit/common/test_http.py @@ -15,7 +15,7 @@ import json -import mock +from unittest import mock from zaqarclient.common import http from zaqarclient.tests import base diff --git a/tests/unit/queues/v1/test_client.py b/tests/unit/queues/v1/test_client.py index 3bcb5f7..604c7af 100644 --- a/tests/unit/queues/v1/test_client.py +++ b/tests/unit/queues/v1/test_client.py @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock +from unittest import mock import ddt diff --git a/tests/unit/queues/v1/test_core.py b/tests/unit/queues/v1/test_core.py index 0abe256..feae62c 100644 --- a/tests/unit/queues/v1/test_core.py +++ b/tests/unit/queues/v1/test_core.py @@ -14,7 +14,7 @@ # limitations under the License. import json -import mock +from unittest import mock from zaqarclient.queues.v1 import core from zaqarclient.tests import base diff --git a/tests/unit/queues/v1/test_message.py b/tests/unit/queues/v1/test_message.py index 5a9bbc3..9d54818 100644 --- a/tests/unit/queues/v1/test_message.py +++ b/tests/unit/queues/v1/test_message.py @@ -14,7 +14,7 @@ # limitations under the License. import json -import mock +from unittest import mock from zaqarclient.queues.v1 import iterator as iterate from zaqarclient.queues.v1 import message diff --git a/tests/unit/queues/v2/test_client.py b/tests/unit/queues/v2/test_client.py index 2c59749..152f990 100644 --- a/tests/unit/queues/v2/test_client.py +++ b/tests/unit/queues/v2/test_client.py @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock +from unittest import mock import ddt diff --git a/tests/unit/queues/v2/test_message.py b/tests/unit/queues/v2/test_message.py index fc22d40..d772570 100644 --- a/tests/unit/queues/v2/test_message.py +++ b/tests/unit/queues/v2/test_message.py @@ -14,7 +14,7 @@ # limitations under the License. import json -import mock +from unittest import mock from zaqarclient.queues.v1 import iterator as iterate from zaqarclient.queues.v2 import message diff --git a/tests/unit/transport/test_http.py b/tests/unit/transport/test_http.py index 218344c..cd079c9 100644 --- a/tests/unit/transport/test_http.py +++ b/tests/unit/transport/test_http.py @@ -13,7 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock +from unittest import mock + import requests as prequest from requests.packages.urllib3 import response diff --git a/tests/unit/transport/test_ws.py b/tests/unit/transport/test_ws.py index aad30de..3b61ef2 100644 --- a/tests/unit/transport/test_ws.py +++ b/tests/unit/transport/test_ws.py @@ -11,7 +11,7 @@ # under the License. import json -import mock +from unittest import mock from zaqarclient.tests import base from zaqarclient.transport import request diff --git a/zaqarclient/tests/queues/base.py b/zaqarclient/tests/queues/base.py index dfea7e1..08a0d9f 100644 --- a/zaqarclient/tests/queues/base.py +++ b/zaqarclient/tests/queues/base.py @@ -13,7 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock +from unittest import mock + from oslo_utils import netutils from zaqarclient.queues import client diff --git a/zaqarclient/tests/queues/claims.py b/zaqarclient/tests/queues/claims.py index 744ec31..a25aba5 100644 --- a/zaqarclient/tests/queues/claims.py +++ b/zaqarclient/tests/queues/claims.py @@ -14,8 +14,8 @@ # limitations under the License. import json -import mock import time +from unittest import mock from zaqarclient.queues.v1 import claim from zaqarclient.tests.queues import base diff --git a/zaqarclient/tests/queues/flavor.py b/zaqarclient/tests/queues/flavor.py index ac8050e..35abf6a 100644 --- a/zaqarclient/tests/queues/flavor.py +++ b/zaqarclient/tests/queues/flavor.py @@ -14,7 +14,7 @@ # limitations under the License. import json -import mock +from unittest import mock from zaqarclient.queues.v1 import iterator from zaqarclient.tests.queues import base diff --git a/zaqarclient/tests/queues/health.py b/zaqarclient/tests/queues/health.py index fa81243..47765fb 100644 --- a/zaqarclient/tests/queues/health.py +++ b/zaqarclient/tests/queues/health.py @@ -14,7 +14,7 @@ # limitations under the License. import json -import mock +from unittest import mock from zaqarclient.tests.queues import base from zaqarclient.transport import response diff --git a/zaqarclient/tests/queues/messages.py b/zaqarclient/tests/queues/messages.py index eb4d686..eadddf2 100644 --- a/zaqarclient/tests/queues/messages.py +++ b/zaqarclient/tests/queues/messages.py @@ -14,7 +14,7 @@ # limitations under the License. import json -import mock +from unittest import mock from zaqarclient.tests.queues import base from zaqarclient.transport import response diff --git a/zaqarclient/tests/queues/pool.py b/zaqarclient/tests/queues/pool.py index e37d1ed..bc6094d 100644 --- a/zaqarclient/tests/queues/pool.py +++ b/zaqarclient/tests/queues/pool.py @@ -14,7 +14,7 @@ # limitations under the License. import json -import mock +from unittest import mock from zaqarclient.queues.v1 import iterator from zaqarclient.tests.queues import base diff --git a/zaqarclient/tests/queues/queues.py b/zaqarclient/tests/queues/queues.py index 572e33f..15b52f8 100644 --- a/zaqarclient/tests/queues/queues.py +++ b/zaqarclient/tests/queues/queues.py @@ -14,7 +14,7 @@ # limitations under the License. import json -import mock +from unittest import mock from zaqarclient import errors from zaqarclient.queues import client diff --git a/zaqarclient/tests/queues/subscriptions.py b/zaqarclient/tests/queues/subscriptions.py index 4ddc91e..ecea0d7 100644 --- a/zaqarclient/tests/queues/subscriptions.py +++ b/zaqarclient/tests/queues/subscriptions.py @@ -14,7 +14,7 @@ # limitations under the License. import json -import mock +from unittest import mock from zaqarclient.tests.queues import base from zaqarclient.transport import errors -- 2.43.0