Replace mock with unittest.mock

mock module has been deprecated in favor of unittest.mock
which is part of the standard python library.

This review removes mock as a third party dependency, and
updates all unittest imports to use unittest.mock instead.

nova-api-proxy had mock as a test requirement, however it
was not using it.

This change has no impact on runtime code.

Test Plan:
  PASS: tox passing for nfv
  PASS: build-pkgs -p nfv
  PASS: tox passing for nova-api-proxy
  PASS: build-pkgs -p nova-api-proxy

Story: 2010531
Task: 47142

Signed-off-by: Al Bailey <al.bailey@windriver.com>
Change-Id: I991d07e87fbdc7fecc4e790550df2472b9b5b24b
This commit is contained in:
Al Bailey 2023-01-19 14:17:03 +00:00
parent d87462c851
commit 0df5aaaf5d
14 changed files with 23 additions and 25 deletions

View File

@ -1,10 +1,10 @@
#
# Copyright (c) 2015-2016 Wind River Systems, Inc.
# Copyright (c) 2015-2023 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
import mock
import random
from unittest import mock
from nfv_vim.network_rebalance._dhcp_rebalance import _add_network_to_dhcp_agent_callback_body # noqa: H501
from nfv_vim.network_rebalance._dhcp_rebalance import _DHCPRebalance

View File

@ -1,10 +1,10 @@
#
# Copyright (c) 2020 Wind River Systems, Inc.
# Copyright (c) 2020-2023 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
import mock
from unittest import mock
import uuid
from nfv_vim import nfvi

View File

@ -1,9 +1,9 @@
#
# Copyright (c) 2015-2016 Wind River Systems, Inc.
# Copyright (c) 2015-2023 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
import mock
from unittest import mock
import uuid
from nfv_vim import nfvi

View File

@ -1,9 +1,9 @@
#
# Copyright (c) 2020-2021 Wind River Systems, Inc.
# Copyright (c) 2020-2023 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
import mock
from unittest import mock
import uuid
from nfv_common import strategy as common_strategy

View File

@ -1,9 +1,9 @@
#
# Copyright (c) 2020-2021 Wind River Systems, Inc.
# Copyright (c) 2020-2023 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
import mock
from unittest import mock
import uuid
from nfv_common import strategy as common_strategy

View File

@ -1,10 +1,10 @@
#
# Copyright (c) 2015-2016 Wind River Systems, Inc.
# Copyright (c) 2015-2023 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
import mock
import random
from unittest import mock
from nfv_vim.network_rebalance._network_rebalance import _L3Rebalance
from nfv_vim.network_rebalance._network_rebalance import _reschedule_down_agent

View File

@ -1,10 +1,10 @@
#
# Copyright (c) 2015-2016 Wind River Systems, Inc.
# Copyright (c) 2015-2023 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
import mock
import random
from unittest import mock
from nfv_vim.network_rebalance._network_rebalance import _add_router_to_agent_callback_body # noqa: H501
from nfv_vim.network_rebalance._network_rebalance import _get_agent_routers_callback_body # noqa: H501

View File

@ -1,11 +1,11 @@
#
# Copyright
# Copyright (c) 2023 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
import copy
import mock
import os
from unittest import mock
from nfv_client import shell

View File

@ -1,4 +1,6 @@
#
# Copyright (c) 2023 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
# Copyright (C) 2019 Intel Corporation
@ -6,7 +8,7 @@
import kubernetes
from kubernetes.client.rest import ApiException
import mock
from unittest import mock
from nfv_plugins.nfvi_plugins.clients import kubernetes_client

View File

@ -1,9 +1,9 @@
#
# Copyright (c) 2016-2020 Wind River Systems, Inc.
# Copyright (c) 2016-2023 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
import mock
from unittest import mock
import uuid
from nfv_common import strategy as common_strategy

View File

@ -1,10 +1,10 @@
#
# Copyright (c) 2016-2020 Wind River Systems, Inc.
# Copyright (c) 2016-2023 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
import mock
import testtools
from unittest import mock
import uuid
from nfv_common import strategy as common_strategy

View File

@ -5,6 +5,5 @@ hacking>=1.1.0,<=2.0.0 # Apache-2.0
bandit
coverage>=3.6
fixtures>=3.0.0 # Apache-2.0/BSD
mock>=2.0.0 # BSD
pylint
testtools>=2.2.0 # MIT

View File

@ -128,7 +128,6 @@ commands = bandit --ini tox.ini -f txt -r {[nfv]nfv_base_dir}
deps = {[nfv]deps}
coverage
fixtures
mock
stestr
testtools
setenv = PYTHONDONTWRITEBYTECODE=True
@ -141,7 +140,6 @@ commands = cp -v {[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/test_data/nfv_vim_
deps = {[nfv]deps}
coverage
fixtures
mock
stestr
testtools
setenv =

View File

@ -5,5 +5,4 @@ hacking>=1.1.0,<=2.0.0 # Apache-2.0
bandit<1.6.0;python_version>="3.0"
coverage>=3.6
fixtures>=3.0.0 # Apache-2.0/BSD
mock>=2.0.0 # BSD
pylint