From 3987688de6720d951bfeb0b49c364df9738b490b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Fri, 22 Nov 2024 14:52:59 +0100 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ář --- tests/helpers.py | 6 +----- tests/test_arch.py | 5 +---- tests/test_arguments.py | 6 +----- tests/test_buildinstall.py | 5 +---- tests/test_checks.py | 6 +----- tests/test_compose.py | 7 +------ tests/test_config.py | 6 +----- tests/test_config_validate_script.py | 5 +---- tests/test_createiso_phase.py | 6 +----- tests/test_createiso_script.py | 9 +++------ tests/test_createrepophase.py | 6 +----- tests/test_extra_files_phase.py | 5 +---- tests/test_extra_isos_phase.py | 7 +------ tests/test_gather_method_deps.py | 5 +---- tests/test_gather_method_hybrid.py | 6 +----- tests/test_gather_method_nodeps.py | 5 +---- tests/test_gather_phase.py | 7 +------ tests/test_gather_source_module.py | 6 +----- tests/test_image_container_phase.py | 6 +----- tests/test_imagebuildphase.py | 6 +----- tests/test_imagechecksumphase.py | 6 +----- tests/test_initphase.py | 7 +------ tests/test_iso_wrapper.py | 6 +----- tests/test_kiwibuildphase.py | 6 +----- tests/test_koji_wrapper.py | 7 +------ tests/test_linker.py | 6 +----- tests/test_livemediaphase.py | 6 +----- tests/test_media_split.py | 6 +----- tests/test_metadata.py | 5 +---- tests/test_notifier.py | 7 +------ tests/test_osbs_phase.py | 5 +---- tests/test_osbuild_phase.py | 6 +----- tests/test_ostree_installer_phase.py | 6 +----- tests/test_ostree_phase.py | 8 +------- tests/test_ostree_script.py | 6 +----- tests/test_ostree_utils.py | 6 +----- tests/test_patch_iso.py | 6 +----- tests/test_phase_base.py | 6 +----- tests/test_pkgset_common.py | 6 +----- tests/test_pkgset_pkgsets.py | 5 +---- tests/test_pkgset_source_koji.py | 6 +----- tests/test_runroot.py | 5 +---- tests/test_scm.py | 6 +----- tests/test_test_phase.py | 5 +---- tests/test_unified_isos.py | 5 +---- tests/test_util.py | 6 +----- 46 files changed, 48 insertions(+), 227 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_arch.py b/tests/test_arch.py index e99c8251..fae515db 100644 --- a/tests/test_arch.py +++ b/tests/test_arch.py @@ -1,9 +1,6 @@ # -*- coding: utf-8 -*- -try: - from unittest import mock -except ImportError: - import mock +from unittest import mock import unittest from pungi.arch import ( diff --git a/tests/test_arguments.py b/tests/test_arguments.py index 479de9c5..460d9263 100644 --- a/tests/test_arguments.py +++ b/tests/test_arguments.py @@ -1,8 +1,4 @@ -try: - from unittest import mock -except ImportError: - import mock - +from unittest import mock import io import unittest diff --git a/tests/test_buildinstall.py b/tests/test_buildinstall.py index 2364e60a..44b53cc8 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 import os diff --git a/tests/test_checks.py b/tests/test_checks.py index 87600b68..c03fab8c 100644 --- a/tests/test_checks.py +++ b/tests/test_checks.py @@ -1,13 +1,9 @@ # -*- coding: utf-8 -*- -try: - from unittest import mock -except ImportError: - 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 6fe9ccea..a3c1938c 100644 --- a/tests/test_compose.py +++ b/tests/test_compose.py @@ -1,17 +1,12 @@ # -*- coding: utf-8 -*- import logging - -try: - from unittest import mock -except ImportError: - 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 df143384..807092f6 100644 --- a/tests/test_createiso_script.py +++ b/tests/test_createiso_script.py @@ -1,13 +1,10 @@ # -*- coding: utf-8 -*- -try: - from unittest import mock -except ImportError: - 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_files_phase.py b/tests/test_extra_files_phase.py index 9d40aa9d..8cb0b6d9 100644 --- a/tests/test_extra_files_phase.py +++ b/tests/test_extra_files_phase.py @@ -1,9 +1,6 @@ # -*- coding: utf-8 -*- -try: - from unittest import mock -except ImportError: - import mock +from unittest import mock import os from productmd.extra_files import ExtraFiles diff --git a/tests/test_extra_isos_phase.py b/tests/test_extra_isos_phase.py index 621219e3..dffe3acf 100644 --- a/tests/test_extra_isos_phase.py +++ b/tests/test_extra_isos_phase.py @@ -1,13 +1,8 @@ # -*- coding: utf-8 -*- import logging - -try: - from unittest import mock -except ImportError: - import mock - import os +from unittest import mock from tests import helpers from pungi.createiso import CreateIsoOpts diff --git a/tests/test_gather_method_deps.py b/tests/test_gather_method_deps.py index 2c77845f..a231681d 100644 --- a/tests/test_gather_method_deps.py +++ b/tests/test_gather_method_deps.py @@ -1,9 +1,6 @@ # -*- coding: utf-8 -*- -try: - from unittest import mock -except ImportError: - import mock +from unittest import mock from pungi.phases.gather.methods import method_deps as deps from tests import helpers diff --git a/tests/test_gather_method_hybrid.py b/tests/test_gather_method_hybrid.py index c707033c..df22b7fc 100644 --- a/tests/test_gather_method_hybrid.py +++ b/tests/test_gather_method_hybrid.py @@ -2,11 +2,7 @@ from collections import namedtuple import copy - -try: - from unittest import mock -except ImportError: - import mock +from unittest import mock import os from pungi.phases.gather.methods import method_hybrid as hybrid diff --git a/tests/test_gather_method_nodeps.py b/tests/test_gather_method_nodeps.py index 1eea55d8..12c5bf50 100644 --- a/tests/test_gather_method_nodeps.py +++ b/tests/test_gather_method_nodeps.py @@ -1,9 +1,6 @@ # -*- coding: utf-8 -*- -try: - from unittest import mock -except ImportError: - import mock +from unittest import mock import os from pungi.phases.gather.methods import method_nodeps as nodeps diff --git a/tests/test_gather_phase.py b/tests/test_gather_phase.py index 8fe851a3..972d6e45 100644 --- a/tests/test_gather_phase.py +++ b/tests/test_gather_phase.py @@ -3,13 +3,8 @@ import copy import json import os - -try: - from unittest import mock -except ImportError: - 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 f4e23cad..ba133ee5 100644 --- a/tests/test_image_container_phase.py +++ b/tests/test_image_container_phase.py @@ -1,10 +1,6 @@ # -*- coding: utf-8 -*- -try: - from unittest import mock -except ImportError: - import mock - +from unittest import mock import os from tests import helpers diff --git a/tests/test_imagebuildphase.py b/tests/test_imagebuildphase.py index c7a7b930..8811565d 100644 --- a/tests/test_imagebuildphase.py +++ b/tests/test_imagebuildphase.py @@ -1,10 +1,6 @@ # -*- coding: utf-8 -*- -try: - from unittest import mock -except ImportError: - import mock - +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_iso_wrapper.py b/tests/test_iso_wrapper.py index a7a84f32..28ea976e 100644 --- a/tests/test_iso_wrapper.py +++ b/tests/test_iso_wrapper.py @@ -1,11 +1,7 @@ # -*- coding: utf-8 -*- import itertools - -try: - from unittest import mock -except ImportError: - import mock +from unittest import mock import os import unittest 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 9bbdf9ab..9e0a5c17 100644 --- a/tests/test_koji_wrapper.py +++ b/tests/test_koji_wrapper.py @@ -1,14 +1,9 @@ # -*- coding: utf-8 -*- import json - -try: - from unittest import mock -except ImportError: - 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 bf1a36b1..87c5a3c1 100644 --- a/tests/test_linker.py +++ b/tests/test_linker.py @@ -1,13 +1,9 @@ # -*- coding: utf-8 -*- - -try: - from unittest import mock -except ImportError: - 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 f4e3c23c..e9c0fbb7 100644 --- a/tests/test_livemediaphase.py +++ b/tests/test_livemediaphase.py @@ -1,10 +1,6 @@ # -*- coding: utf-8 -*- -try: - from unittest import mock -except ImportError: - import mock - +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_metadata.py b/tests/test_metadata.py index bc351963..a10ce4a0 100644 --- a/tests/test_metadata.py +++ b/tests/test_metadata.py @@ -1,7 +1,4 @@ -try: - from unittest import mock -except ImportError: - import mock +from unittest import mock import os from tests import helpers diff --git a/tests/test_notifier.py b/tests/test_notifier.py index fd62aea1..e5584cc6 100644 --- a/tests/test_notifier.py +++ b/tests/test_notifier.py @@ -2,13 +2,8 @@ from datetime import datetime import json - -try: - from unittest import mock -except ImportError: - import mock - import unittest +from unittest import mock from pungi.notifier import PungiNotifier diff --git a/tests/test_osbs_phase.py b/tests/test_osbs_phase.py index 369adc8d..7836e651 100644 --- a/tests/test_osbs_phase.py +++ b/tests/test_osbs_phase.py @@ -1,9 +1,6 @@ # -*- coding: utf-8 -*- -try: - from unittest import mock -except ImportError: - import mock +from unittest import mock import json import copy diff --git a/tests/test_osbuild_phase.py b/tests/test_osbuild_phase.py index 4ee82aa7..0779da92 100644 --- a/tests/test_osbuild_phase.py +++ b/tests/test_osbuild_phase.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_ostree_installer_phase.py b/tests/test_ostree_installer_phase.py index 69095d09..45c34a63 100644 --- a/tests/test_ostree_installer_phase.py +++ b/tests/test_ostree_installer_phase.py @@ -1,10 +1,6 @@ # -*- coding: utf-8 -*- -try: - from unittest import mock -except ImportError: - import mock - +from unittest import mock import os import shlex diff --git a/tests/test_ostree_phase.py b/tests/test_ostree_phase.py index 96b4aaae..cf322c06 100644 --- a/tests/test_ostree_phase.py +++ b/tests/test_ostree_phase.py @@ -1,13 +1,7 @@ # -*- coding: utf-8 -*- - import json - -try: - from unittest import mock -except ImportError: - import mock - +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 4f9246f4..85d099aa 100644 --- a/tests/test_ostree_utils.py +++ b/tests/test_ostree_utils.py @@ -1,10 +1,6 @@ # -*- coding: utf-8 -*- -try: - from unittest import mock -except ImportError: - import mock - +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 ac81b2a0..e1520e52 100644 --- a/tests/test_phase_base.py +++ b/tests/test_phase_base.py @@ -1,13 +1,9 @@ # -*- coding: utf-8 -*- -try: - from unittest import mock -except ImportError: - 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 3deb7830..9e109f60 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 1219b53c..b0e235fa 100644 --- a/tests/test_pkgset_pkgsets.py +++ b/tests/test_pkgset_pkgsets.py @@ -1,9 +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_pkgset_source_koji.py b/tests/test_pkgset_source_koji.py index 4a545e55..f81847d8 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_runroot.py b/tests/test_runroot.py index 18a12684..bbc77740 100644 --- a/tests/test_runroot.py +++ b/tests/test_runroot.py @@ -1,9 +1,6 @@ # -*- coding: utf-8 -*- -try: - from unittest import mock -except ImportError: - import mock +from unittest import mock import os from pungi.runroot import Runroot diff --git a/tests/test_scm.py b/tests/test_scm.py index 2f8c47b6..534492da 100644 --- a/tests/test_scm.py +++ b/tests/test_scm.py @@ -1,10 +1,6 @@ # -*- coding: utf-8 -*- -try: - from unittest import mock -except ImportError: - import mock - +from unittest import mock import os import random import shutil diff --git a/tests/test_test_phase.py b/tests/test_test_phase.py index fb0751e9..fb48d8be 100644 --- a/tests/test_test_phase.py +++ b/tests/test_test_phase.py @@ -1,9 +1,6 @@ # -*- coding: utf-8 -*- -try: - from unittest import mock -except ImportError: - import mock +from unittest import mock import os import pungi.phases.test as test_phase diff --git a/tests/test_unified_isos.py b/tests/test_unified_isos.py index ee3fc0ad..bf095d9c 100755 --- a/tests/test_unified_isos.py +++ b/tests/test_unified_isos.py @@ -1,12 +1,9 @@ # -*- coding: utf-8 -*- -try: - from unittest import mock -except ImportError: - 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 diff --git a/tests/test_util.py b/tests/test_util.py index 5084a3ca..cf281c8a 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -1,11 +1,7 @@ # -*- coding: utf-8 -*- import argparse - -try: - from unittest import mock -except ImportError: - import mock +from unittest import mock import os import unittest