From fddce94704c320e0df4eeee4b7376be831da05b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Fri, 22 Nov 2024 15:52:59 +0200 Subject: [PATCH] Directly import mock from unittest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is not a separate package since Python 3.3 Signed-off-by: Lubomír Sedlář (cherry picked from commit 3987688de6720d951bfeb0b49c364df9738b490b) --- tests/helpers.py | 6 +----- tests/test_arguments.py | 1 - tests/test_buildinstall.py | 5 +---- tests/test_checks.py | 3 +-- tests/test_compose.py | 3 +-- tests/test_config.py | 6 +----- tests/test_config_validate_script.py | 5 +---- tests/test_createiso_phase.py | 6 +----- tests/test_createiso_script.py | 6 +++--- tests/test_createrepophase.py | 6 +----- tests/test_extra_isos_phase.py | 9 ++------- tests/test_gather_phase.py | 4 +--- tests/test_gather_source_module.py | 6 +----- tests/test_image_container_phase.py | 1 - tests/test_imagebuildphase.py | 1 - tests/test_imagechecksumphase.py | 6 +----- tests/test_initphase.py | 7 +------ tests/test_kiwibuildphase.py | 6 +----- tests/test_koji_wrapper.py | 3 +-- tests/test_linker.py | 3 +-- tests/test_livemediaphase.py | 1 - tests/test_media_split.py | 6 +----- tests/test_notifier.py | 3 +-- tests/test_osbuild_phase.py | 1 - tests/test_ostree_installer_phase.py | 1 - tests/test_ostree_phase.py | 2 -- tests/test_ostree_script.py | 6 +----- tests/test_ostree_utils.py | 1 - tests/test_patch_iso.py | 6 +----- tests/test_phase_base.py | 3 +-- tests/test_pkgset_common.py | 6 +----- tests/test_pkgset_pkgsets.py | 2 +- tests/test_pkgset_source_koji.py | 6 +----- tests/test_scm.py | 1 - tests/test_unified_isos.py | 2 +- 35 files changed, 29 insertions(+), 111 deletions(-) diff --git a/tests/helpers.py b/tests/helpers.py index 51a7d013..d722a515 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -7,11 +7,7 @@ import os import shutil import tempfile from collections import defaultdict - -try: - from unittest import mock -except ImportError: - import mock +from unittest import mock from kobo.rpmlib import parse_nvr import unittest diff --git a/tests/test_arguments.py b/tests/test_arguments.py index a5702b5b..460d9263 100644 --- a/tests/test_arguments.py +++ b/tests/test_arguments.py @@ -1,5 +1,4 @@ from unittest import mock - import io import unittest diff --git a/tests/test_buildinstall.py b/tests/test_buildinstall.py index 1080f40a..8ae0941d 100644 --- a/tests/test_buildinstall.py +++ b/tests/test_buildinstall.py @@ -1,11 +1,8 @@ # -*- coding: utf-8 -*- -try: - from unittest import mock -except ImportError: - import mock from copy import copy from io import StringIO +from unittest import mock from ddt import ddt, data import os diff --git a/tests/test_checks.py b/tests/test_checks.py index f23afcc6..c03fab8c 100644 --- a/tests/test_checks.py +++ b/tests/test_checks.py @@ -1,10 +1,9 @@ # -*- coding: utf-8 -*- -from unittest import mock - import unittest import os from io import StringIO +from unittest import mock import kobo.conf diff --git a/tests/test_compose.py b/tests/test_compose.py index 4ef8de49..a3c1938c 100644 --- a/tests/test_compose.py +++ b/tests/test_compose.py @@ -1,13 +1,12 @@ # -*- coding: utf-8 -*- import logging -from unittest import mock - import json import os import shutil import tempfile import unittest +from unittest import mock from requests.exceptions import HTTPError diff --git a/tests/test_config.py b/tests/test_config.py index 68f5bd62..69be03c8 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -1,11 +1,7 @@ # -*- coding: utf-8 -*- import unittest - -try: - from unittest import mock -except ImportError: - import mock +from unittest import mock from pungi import checks from tests.helpers import load_config, PKGSET_REPOS diff --git a/tests/test_config_validate_script.py b/tests/test_config_validate_script.py index 1d96f8b8..8cb713b8 100644 --- a/tests/test_config_validate_script.py +++ b/tests/test_config_validate_script.py @@ -1,9 +1,6 @@ # -*- coding: utf-8 -*- -try: - from unittest import mock -except ImportError: - import mock +from unittest import mock import io import os diff --git a/tests/test_createiso_phase.py b/tests/test_createiso_phase.py index 11239cb6..76c7c62d 100644 --- a/tests/test_createiso_phase.py +++ b/tests/test_createiso_phase.py @@ -3,11 +3,7 @@ import logging import contextlib - -try: - from unittest import mock -except ImportError: - import mock +from unittest import mock import productmd import os diff --git a/tests/test_createiso_script.py b/tests/test_createiso_script.py index 264ae449..807092f6 100644 --- a/tests/test_createiso_script.py +++ b/tests/test_createiso_script.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- -from unittest import mock -from parameterized import parameterized - import os from io import StringIO +from unittest import mock + +from parameterized import parameterized from tests import helpers from pungi import createiso diff --git a/tests/test_createrepophase.py b/tests/test_createrepophase.py index e2d84323..eecd4a45 100644 --- a/tests/test_createrepophase.py +++ b/tests/test_createrepophase.py @@ -3,11 +3,7 @@ import glob import os import unittest - -try: - from unittest import mock -except ImportError: - import mock +from unittest import mock from pungi.module_util import Modulemd from pungi.phases.createrepo import ( diff --git a/tests/test_extra_isos_phase.py b/tests/test_extra_isos_phase.py index f09bf26c..52bf03b3 100644 --- a/tests/test_extra_isos_phase.py +++ b/tests/test_extra_isos_phase.py @@ -1,14 +1,9 @@ # -*- coding: utf-8 -*- import logging - -try: - from unittest import mock -except ImportError: - import mock -from typing import AnyStr, List - import os +from unittest import mock +from typing import AnyStr, List from tests import helpers from pungi.createiso import CreateIsoOpts diff --git a/tests/test_gather_phase.py b/tests/test_gather_phase.py index e47c171e..972d6e45 100644 --- a/tests/test_gather_phase.py +++ b/tests/test_gather_phase.py @@ -3,10 +3,8 @@ import copy import json import os - -from unittest import mock - import unittest +from unittest import mock from pungi.phases import gather from pungi.phases.gather import _mk_pkg_map diff --git a/tests/test_gather_source_module.py b/tests/test_gather_source_module.py index 93496eaf..73aacc80 100644 --- a/tests/test_gather_source_module.py +++ b/tests/test_gather_source_module.py @@ -1,11 +1,7 @@ # -*- coding: utf-8 -*- import unittest - -try: - from unittest import mock -except ImportError: - import mock +from unittest import mock from pungi.phases.gather.sources.source_module import GatherSourceModule from tests import helpers diff --git a/tests/test_image_container_phase.py b/tests/test_image_container_phase.py index ab6a301b..ba133ee5 100644 --- a/tests/test_image_container_phase.py +++ b/tests/test_image_container_phase.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- from unittest import mock - import os from tests import helpers diff --git a/tests/test_imagebuildphase.py b/tests/test_imagebuildphase.py index 6fbd457c..8811565d 100644 --- a/tests/test_imagebuildphase.py +++ b/tests/test_imagebuildphase.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- from unittest import mock - import os from pungi.phases.image_build import ImageBuildPhase, CreateImageBuildThread diff --git a/tests/test_imagechecksumphase.py b/tests/test_imagechecksumphase.py index 50187324..13c7863e 100644 --- a/tests/test_imagechecksumphase.py +++ b/tests/test_imagechecksumphase.py @@ -1,10 +1,6 @@ # -*- coding: utf-8 -*- -try: - from unittest import mock -except ImportError: - import mock - +from unittest import mock import os import shutil import tempfile diff --git a/tests/test_initphase.py b/tests/test_initphase.py index 90a75728..f4b82ef2 100644 --- a/tests/test_initphase.py +++ b/tests/test_initphase.py @@ -2,12 +2,7 @@ import unittest - -try: - from unittest import mock -except ImportError: - import mock - +from unittest import mock import os from pungi.module_util import Modulemd diff --git a/tests/test_kiwibuildphase.py b/tests/test_kiwibuildphase.py index e3ccdb72..f43219d3 100644 --- a/tests/test_kiwibuildphase.py +++ b/tests/test_kiwibuildphase.py @@ -1,9 +1,5 @@ import os - -try: - from unittest import mock -except ImportError: - import mock +from unittest import mock from pungi.phases.kiwibuild import KiwiBuildPhase, RunKiwiBuildThread from tests.helpers import DummyCompose, PungiTestCase diff --git a/tests/test_koji_wrapper.py b/tests/test_koji_wrapper.py index 015899c7..9e0a5c17 100644 --- a/tests/test_koji_wrapper.py +++ b/tests/test_koji_wrapper.py @@ -1,10 +1,9 @@ # -*- coding: utf-8 -*- import json -from unittest import mock - import unittest import tempfile +from unittest import mock import os import shutil diff --git a/tests/test_linker.py b/tests/test_linker.py index 93f1d4fe..87c5a3c1 100644 --- a/tests/test_linker.py +++ b/tests/test_linker.py @@ -1,10 +1,9 @@ # -*- coding: utf-8 -*- - -from unittest import mock import errno import os import stat +from unittest import mock from pungi import linker from tests import helpers diff --git a/tests/test_livemediaphase.py b/tests/test_livemediaphase.py index 18489fc0..e9c0fbb7 100644 --- a/tests/test_livemediaphase.py +++ b/tests/test_livemediaphase.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- from unittest import mock - import os from pungi.phases.livemedia_phase import LiveMediaPhase, LiveMediaThread diff --git a/tests/test_media_split.py b/tests/test_media_split.py index 320f196a..beeb7d72 100644 --- a/tests/test_media_split.py +++ b/tests/test_media_split.py @@ -1,11 +1,7 @@ # -*- coding: utf-8 -*- import unittest - -try: - from unittest import mock -except ImportError: - import mock +from unittest import mock from pungi import media_split diff --git a/tests/test_notifier.py b/tests/test_notifier.py index 46645543..e5584cc6 100644 --- a/tests/test_notifier.py +++ b/tests/test_notifier.py @@ -2,9 +2,8 @@ from datetime import datetime import json -from unittest import mock - import unittest +from unittest import mock from pungi.notifier import PungiNotifier diff --git a/tests/test_osbuild_phase.py b/tests/test_osbuild_phase.py index fdab383a..0779da92 100644 --- a/tests/test_osbuild_phase.py +++ b/tests/test_osbuild_phase.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- from unittest import mock - import os import shutil import tempfile diff --git a/tests/test_ostree_installer_phase.py b/tests/test_ostree_installer_phase.py index 7fa28ee0..45c34a63 100644 --- a/tests/test_ostree_installer_phase.py +++ b/tests/test_ostree_installer_phase.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- from unittest import mock - import os import shlex diff --git a/tests/test_ostree_phase.py b/tests/test_ostree_phase.py index ca061768..cf322c06 100644 --- a/tests/test_ostree_phase.py +++ b/tests/test_ostree_phase.py @@ -1,9 +1,7 @@ # -*- coding: utf-8 -*- - import json from unittest import mock - import os from tests import helpers diff --git a/tests/test_ostree_script.py b/tests/test_ostree_script.py index 10326c9c..6276f729 100644 --- a/tests/test_ostree_script.py +++ b/tests/test_ostree_script.py @@ -3,12 +3,8 @@ import json import os - -try: - from unittest import mock -except ImportError: - import mock import yaml +from unittest import mock from tests import helpers from pungi import ostree diff --git a/tests/test_ostree_utils.py b/tests/test_ostree_utils.py index 1fe03608..85d099aa 100644 --- a/tests/test_ostree_utils.py +++ b/tests/test_ostree_utils.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- from unittest import mock - import os from tests import helpers diff --git a/tests/test_patch_iso.py b/tests/test_patch_iso.py index 9927c0e5..87e052d0 100644 --- a/tests/test_patch_iso.py +++ b/tests/test_patch_iso.py @@ -1,10 +1,6 @@ # -*- coding: utf-8 -*- -try: - from unittest import mock -except ImportError: - import mock - +from unittest import mock import os import unittest diff --git a/tests/test_phase_base.py b/tests/test_phase_base.py index 35491478..e1520e52 100644 --- a/tests/test_phase_base.py +++ b/tests/test_phase_base.py @@ -1,10 +1,9 @@ # -*- coding: utf-8 -*- -from unittest import mock - import unittest import random import time +from unittest import mock from pungi.phases import weaver from tests.helpers import DummyCompose, boom diff --git a/tests/test_pkgset_common.py b/tests/test_pkgset_common.py index f4f8f7c5..c358a907 100755 --- a/tests/test_pkgset_common.py +++ b/tests/test_pkgset_common.py @@ -1,11 +1,7 @@ # -*- coding: utf-8 -*- import os - -try: - from unittest import mock -except ImportError: - import mock +from unittest import mock from pungi.module_util import Modulemd from pungi.phases.pkgset import common diff --git a/tests/test_pkgset_pkgsets.py b/tests/test_pkgset_pkgsets.py index c96c3359..5435a2e4 100644 --- a/tests/test_pkgset_pkgsets.py +++ b/tests/test_pkgset_pkgsets.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- -import ddt from unittest import mock import os +import ddt import unittest import json import tempfile diff --git a/tests/test_pkgset_source_koji.py b/tests/test_pkgset_source_koji.py index 56488916..8f0d59ac 100644 --- a/tests/test_pkgset_source_koji.py +++ b/tests/test_pkgset_source_koji.py @@ -1,11 +1,7 @@ # -*- coding: utf-8 -*- import json - -try: - from unittest import mock -except ImportError: - import mock +from unittest import mock import os import re import unittest diff --git a/tests/test_scm.py b/tests/test_scm.py index 39f120d2..534492da 100644 --- a/tests/test_scm.py +++ b/tests/test_scm.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- from unittest import mock - import os import random import shutil diff --git a/tests/test_unified_isos.py b/tests/test_unified_isos.py index 15deca06..bf095d9c 100755 --- a/tests/test_unified_isos.py +++ b/tests/test_unified_isos.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- -from unittest import mock import os import shutil from configparser import ConfigParser +from unittest import mock from tests.helpers import PungiTestCase, FIXTURE_DIR, touch, mk_boom from pungi_utils import unified_isos