From 27b46f97451c70b44f4eeff6569725c68a58b4cc Mon Sep 17 00:00:00 2001 From: Victor Seva <vseva@sipwise.com> Date: Wed, 19 Jan 2022 15:18:59 +0100 Subject: [PATCH] TT#121955 use mock from unittest * mock is now part of the Python standard library, available as unittest.mock in Python 3.3 onwards. https://pypi.org/project/mock/ Change-Id: Id5a5d4a5020821def08a3cbf2a6d528d43c4d48c --- hotfix/test/test_hotfix_released.py | 8 ++++---- release_dashboard/test/test_rest.py | 7 ++++--- release_dashboard/test/test_tasks_build.py | 7 ++++--- release_dashboard/test/test_utils_docker.py | 9 +++++---- repoapi/test/test_basic_model.py | 6 +++--- repoapi/test/test_jbi_info.py | 8 ++++---- repoapi/test/test_utils.py | 5 +++-- repoapi/test/test_workfrontnote.py | 5 +++-- requirements/test.txt | 1 - 9 files changed, 30 insertions(+), 26 deletions(-) diff --git a/hotfix/test/test_hotfix_released.py b/hotfix/test/test_hotfix_released.py index b529927..d98db07 100644 --- a/hotfix/test/test_hotfix_released.py +++ b/hotfix/test/test_hotfix_released.py @@ -1,4 +1,4 @@ -# Copyright (C) 2015 The Sipwise Team - http://sipwise.com +# Copyright (C) 2015-2022 The Sipwise Team - http://sipwise.com # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free @@ -12,9 +12,9 @@ # # You should have received a copy of the GNU General Public License along # with this program. If not, see <http://www.gnu.org/licenses/>. -from mock import call -from mock import mock_open -from mock import patch +from unittest.mock import call +from unittest.mock import mock_open +from unittest.mock import patch from hotfix import models from hotfix import utils diff --git a/release_dashboard/test/test_rest.py b/release_dashboard/test/test_rest.py index 34c6eba..dcb05a3 100644 --- a/release_dashboard/test/test_rest.py +++ b/release_dashboard/test/test_rest.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017-2020 The Sipwise Team - http://sipwise.com +# Copyright (C) 2017-2022 The Sipwise Team - http://sipwise.com # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free @@ -12,10 +12,11 @@ # # You should have received a copy of the GNU General Public License along # with this program. If not, see <http://www.gnu.org/licenses/>. +from unittest.mock import call +from unittest.mock import patch + from django.test import override_settings from django.urls import reverse -from mock import call -from mock import patch from rest_framework import status from rest_framework.test import APITestCase diff --git a/release_dashboard/test/test_tasks_build.py b/release_dashboard/test/test_tasks_build.py index 5923042..c1e1c94 100644 --- a/release_dashboard/test/test_tasks_build.py +++ b/release_dashboard/test/test_tasks_build.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017 The Sipwise Team - http://sipwise.com +# Copyright (C) 2017-20222 The Sipwise Team - http://sipwise.com # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free @@ -11,9 +11,10 @@ # more details. # # You should have received a copy of the GNU General Public License along -# with this prograproj. If not, see <http://www.gnu.org/licenses/>. +# with this program. If not, see <http://www.gnu.org/licenses/>. +from unittest.mock import patch + from django.test import SimpleTestCase -from mock import patch from release_dashboard import tasks diff --git a/release_dashboard/test/test_utils_docker.py b/release_dashboard/test/test_utils_docker.py index 1caaf84..5842a5a 100644 --- a/release_dashboard/test/test_utils_docker.py +++ b/release_dashboard/test/test_utils_docker.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017 The Sipwise Team - http://sipwise.com +# Copyright (C) 2017-2022 The Sipwise Team - http://sipwise.com # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free @@ -11,11 +11,12 @@ # more details. # # You should have received a copy of the GNU General Public License along -# with this prograproj. If not, see <http://www.gnu.org/licenses/>. +# with this program. If not, see <http://www.gnu.org/licenses/>. +from unittest.mock import call +from unittest.mock import patch + from django.test import override_settings from django.test import SimpleTestCase -from mock import call -from mock import patch from release_dashboard.utils import docker diff --git a/repoapi/test/test_basic_model.py b/repoapi/test/test_basic_model.py index 83d6870..9cf7c34 100644 --- a/repoapi/test/test_basic_model.py +++ b/repoapi/test/test_basic_model.py @@ -1,4 +1,4 @@ -# Copyright (C) 2015-2020 The Sipwise Team - http://sipwise.com +# Copyright (C) 2015-2022 The Sipwise Team - http://sipwise.com # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free @@ -13,10 +13,10 @@ # You should have received a copy of the GNU General Public License along # with this program. If not, see <http://www.gnu.org/licenses/>. from os.path import join +from unittest.mock import mock_open +from unittest.mock import patch from django.test import override_settings -from mock import mock_open -from mock import patch from .base import BaseTest from repoapi.conf import settings diff --git a/repoapi/test/test_jbi_info.py b/repoapi/test/test_jbi_info.py index 0ae5af6..0dfc79b 100644 --- a/repoapi/test/test_jbi_info.py +++ b/repoapi/test/test_jbi_info.py @@ -1,4 +1,4 @@ -# Copyright (C) 2015 The Sipwise Team - http://sipwise.com +# Copyright (C) 2015-2022 The Sipwise Team - http://sipwise.com # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free @@ -13,11 +13,11 @@ # You should have received a copy of the GNU General Public License along # with this program. If not, see <http://www.gnu.org/licenses/>. import os +from unittest.mock import call +from unittest.mock import mock_open +from unittest.mock import patch from django.conf import settings -from mock import call -from mock import mock_open -from mock import patch from repoapi.models import JenkinsBuildInfo from repoapi.test.base import BaseTest diff --git a/repoapi/test/test_utils.py b/repoapi/test/test_utils.py index 94ab486..b3cc3e3 100644 --- a/repoapi/test/test_utils.py +++ b/repoapi/test/test_utils.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017-2020 The Sipwise Team - http://sipwise.com +# Copyright (C) 2017-2022 The Sipwise Team - http://sipwise.com # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free @@ -12,8 +12,9 @@ # # You should have received a copy of the GNU General Public License along # with this program. If not, see <http://www.gnu.org/licenses/>. +from unittest.mock import patch + from django.test import override_settings -from mock import patch from repoapi import utils from repoapi.test.base import BaseTest diff --git a/repoapi/test/test_workfrontnote.py b/repoapi/test/test_workfrontnote.py index df44356..470d34a 100644 --- a/repoapi/test/test_workfrontnote.py +++ b/repoapi/test/test_workfrontnote.py @@ -1,4 +1,4 @@ -# Copyright (C) 2016 The Sipwise Team - http://sipwise.com +# Copyright (C) 2016-2022 The Sipwise Team - http://sipwise.com # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free @@ -12,8 +12,9 @@ # # You should have received a copy of the GNU General Public License along # with this program. If not, see <http://www.gnu.org/licenses/>. +from unittest.mock import patch + from django.conf import settings -from mock import patch from repoapi.models import JenkinsBuildInfo from repoapi.models import WorkfrontNoteInfo diff --git a/requirements/test.txt b/requirements/test.txt index 9510461..6624a30 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -1,2 +1 @@ -r common.txt -mock