From 4b08096d237419e42f456c0892375d122c1368c7 Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Tue, 24 Mar 2020 07:47:14 -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: Ida2ec7793c3863836e1c626eb72e0aa9f48b6810 Signed-off-by: Sean McGinnis --- adjutant/actions/v1/tests/test_misc_actions.py | 5 ++--- adjutant/actions/v1/tests/test_project_actions.py | 2 +- adjutant/actions/v1/tests/test_resource_actions.py | 2 +- adjutant/actions/v1/tests/test_user_actions.py | 2 +- adjutant/api/v1/tests/test_api_admin.py | 6 ++---- adjutant/api/v1/tests/test_api_openstack.py | 8 +++----- adjutant/api/v1/tests/test_api_taskview.py | 8 +++----- adjutant/common/tests/fake_clients.py | 3 +-- adjutant/notifications/v1/tests/test_notifications.py | 8 +++----- test-requirements.txt | 3 +-- 10 files changed, 18 insertions(+), 29 deletions(-) diff --git a/adjutant/actions/v1/tests/test_misc_actions.py b/adjutant/actions/v1/tests/test_misc_actions.py index adcbbb2..29ae2c8 100644 --- a/adjutant/actions/v1/tests/test_misc_actions.py +++ b/adjutant/actions/v1/tests/test_misc_actions.py @@ -12,12 +12,11 @@ # License for the specific language governing permissions and limitations # under the License. -import mock from smtplib import SMTPException - -from django.core import mail +from unittest import mock from confspirator.tests import utils as conf_utils +from django.core import mail from adjutant.actions.v1.misc import SendAdditionalEmailAction from adjutant.actions.utils import send_email diff --git a/adjutant/actions/v1/tests/test_project_actions.py b/adjutant/actions/v1/tests/test_project_actions.py index b27bccc..73e61d5 100644 --- a/adjutant/actions/v1/tests/test_project_actions.py +++ b/adjutant/actions/v1/tests/test_project_actions.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from confspirator.tests import utils as conf_utils diff --git a/adjutant/actions/v1/tests/test_resource_actions.py b/adjutant/actions/v1/tests/test_resource_actions.py index 63821be..3ebcc09 100644 --- a/adjutant/actions/v1/tests/test_resource_actions.py +++ b/adjutant/actions/v1/tests/test_resource_actions.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from confspirator.tests import utils as conf_utils diff --git a/adjutant/actions/v1/tests/test_user_actions.py b/adjutant/actions/v1/tests/test_user_actions.py index f590555..409472f 100644 --- a/adjutant/actions/v1/tests/test_user_actions.py +++ b/adjutant/actions/v1/tests/test_user_actions.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from confspirator.tests import utils as conf_utils diff --git a/adjutant/api/v1/tests/test_api_admin.py b/adjutant/api/v1/tests/test_api_admin.py index 0c197b8..d4e254d 100644 --- a/adjutant/api/v1/tests/test_api_admin.py +++ b/adjutant/api/v1/tests/test_api_admin.py @@ -14,17 +14,15 @@ from datetime import timedelta import json -import mock +from unittest import mock from unittest import skip +from confspirator.tests import utils as conf_utils from django.utils import timezone from django.core import mail - from rest_framework import status from rest_framework.test import APITestCase -from confspirator.tests import utils as conf_utils - from adjutant.api.models import Task, Token, Notification from adjutant.common.tests import fake_clients from adjutant.common.tests.fake_clients import FakeManager, setup_identity_cache diff --git a/adjutant/api/v1/tests/test_api_openstack.py b/adjutant/api/v1/tests/test_api_openstack.py index afe0cf4..ee1ca69 100644 --- a/adjutant/api/v1/tests/test_api_openstack.py +++ b/adjutant/api/v1/tests/test_api_openstack.py @@ -13,13 +13,11 @@ # under the License. from datetime import timedelta -import mock - -from rest_framework import status - -from django.utils import timezone +from unittest import mock from confspirator.tests import utils as conf_utils +from django.utils import timezone +from rest_framework import status from adjutant.api.models import Token, Task from adjutant.common.tests import fake_clients diff --git a/adjutant/api/v1/tests/test_api_taskview.py b/adjutant/api/v1/tests/test_api_taskview.py index ce2214c..3ecb0e0 100644 --- a/adjutant/api/v1/tests/test_api_taskview.py +++ b/adjutant/api/v1/tests/test_api_taskview.py @@ -12,13 +12,11 @@ # License for the specific language governing permissions and limitations # under the License. -import mock - -from django.core import mail - -from rest_framework import status +from unittest import mock from confspirator.tests import utils as conf_utils +from django.core import mail +from rest_framework import status from adjutant.api.models import Token, Notification from adjutant.tasks.models import Task diff --git a/adjutant/common/tests/fake_clients.py b/adjutant/common/tests/fake_clients.py index af279cb..ebdb514 100644 --- a/adjutant/common/tests/fake_clients.py +++ b/adjutant/common/tests/fake_clients.py @@ -12,10 +12,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock from uuid import uuid4 -import mock - from adjutant.config import CONF diff --git a/adjutant/notifications/v1/tests/test_notifications.py b/adjutant/notifications/v1/tests/test_notifications.py index 49c5b69..edd9a36 100644 --- a/adjutant/notifications/v1/tests/test_notifications.py +++ b/adjutant/notifications/v1/tests/test_notifications.py @@ -12,13 +12,11 @@ # License for the specific language governing permissions and limitations # under the License. -import mock - -from django.core import mail - -from rest_framework import status +from unittest import mock from confspirator.tests import utils as conf_utils +from django.core import mail +from rest_framework import status from adjutant.api.models import Notification from adjutant.tasks.models import Task diff --git a/test-requirements.txt b/test-requirements.txt index 66aed5d..77bddba 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -6,7 +6,6 @@ flake8>=3.7.7 # MIT coverage>=4.5.3 # Apache-2.0 doc8>=0.8.0 # Apache-2.0 -mock>=3.0.0 # BSD Pygments>=2.2.0 # BSD license flake8-bugbear>=19.3.0;python_version>='3.4' # MIT -black>=19.3b0;python_version>='3.4' # MIT \ No newline at end of file +black>=19.3b0;python_version>='3.4' # MIT