From 755004af02636022df399f473b58616016294dc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Wed, 13 Mar 2024 14:46:30 +0200 Subject: [PATCH] Drop unittest2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The library is imported if available, but we never build it in any environment where the package would be installed. It was last used for RHEL 6 builds. Signed-off-by: Lubomír Sedlář (cherry picked from commit d95d1f59e2ae243ea794c5f5613fef3249b4fad6) --- test-requirements.txt | 1 - tests/helpers.py | 5 +---- tests/test_arguments.py | 5 +---- tests/test_buildinstall.py | 5 +---- tests/test_checks.py | 5 +---- tests/test_compose.py | 9 +++------ tests/test_comps_wrapper.py | 5 +---- tests/test_config.py | 6 +----- tests/test_config_utils.py | 5 +---- tests/test_createrepo_wrapper.py | 5 +---- tests/test_createrepophase.py | 6 +----- tests/test_fus_wrapper.py | 5 +---- tests/test_gather.py | 11 +++-------- tests/test_gather_phase.py | 5 +---- tests/test_gather_source_module.py | 5 +---- tests/test_graph.py | 5 +---- tests/test_imagechecksumphase.py | 8 ++++---- tests/test_initphase.py | 7 ++++--- tests/test_iso_wrapper.py | 6 +----- tests/test_koji_wrapper.py | 5 +---- tests/test_lorax_wrapper.py | 5 +---- tests/test_media_split.py | 7 ++++--- tests/test_module_util.py | 5 +---- tests/test_notifier.py | 5 +---- tests/test_patch_iso.py | 10 +++++----- tests/test_phase_base.py | 5 +---- tests/test_pkgset_pkgsets.py | 5 +---- tests/test_pkgset_source_koji.py | 9 ++++++--- tests/test_repoclosure_phase.py | 5 +---- tests/test_scm.py | 9 +++------ tests/test_util.py | 5 +---- tests/test_variant_wrapper.py | 5 +---- 32 files changed, 55 insertions(+), 134 deletions(-) diff --git a/test-requirements.txt b/test-requirements.txt index db667730..338b8ff3 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -2,4 +2,3 @@ mock; python_version < '3.3' parameterized pytest pytest-cov -unittest2; python_version < '3.0' diff --git a/tests/helpers.py b/tests/helpers.py index ef2e9abc..569a53d0 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -12,10 +12,7 @@ from unittest import mock import six from kobo.rpmlib import parse_nvr -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from pungi.util import get_arch_variant_data from pungi import paths, checks diff --git a/tests/test_arguments.py b/tests/test_arguments.py index 42baacf4..55ca28e1 100644 --- a/tests/test_arguments.py +++ b/tests/test_arguments.py @@ -1,9 +1,6 @@ from unittest import mock -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import six from pungi.scripts.pungi_koji import cli_main diff --git a/tests/test_buildinstall.py b/tests/test_buildinstall.py index 0ab478a7..61e90575 100644 --- a/tests/test_buildinstall.py +++ b/tests/test_buildinstall.py @@ -1,9 +1,6 @@ # -*- coding: utf-8 -*- -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from unittest import mock import six diff --git a/tests/test_checks.py b/tests/test_checks.py index 6ff46bdf..2cd662ef 100644 --- a/tests/test_checks.py +++ b/tests/test_checks.py @@ -2,10 +2,7 @@ from unittest import mock -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import os from six import StringIO diff --git a/tests/test_compose.py b/tests/test_compose.py index 07f32b59..67ba2fe4 100644 --- a/tests/test_compose.py +++ b/tests/test_compose.py @@ -3,15 +3,12 @@ import logging from unittest import mock -try: - import unittest2 as unittest -except ImportError: - import unittest +import json import os +import shutil import six import tempfile -import shutil -import json +import unittest from requests.exceptions import HTTPError diff --git a/tests/test_comps_wrapper.py b/tests/test_comps_wrapper.py index cee03dcb..c2ae20c7 100644 --- a/tests/test_comps_wrapper.py +++ b/tests/test_comps_wrapper.py @@ -1,10 +1,7 @@ # -*- coding: utf-8 -*- -try: - import unittest2 as unittest -except ImportError: - import unittest import tempfile +import unittest import os diff --git a/tests/test_config.py b/tests/test_config.py index 26f68d1d..b7eb533f 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -1,10 +1,6 @@ # -*- coding: utf-8 -*- - -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import six from unittest import mock diff --git a/tests/test_config_utils.py b/tests/test_config_utils.py index 571de650..bc019f8c 100644 --- a/tests/test_config_utils.py +++ b/tests/test_config_utils.py @@ -1,10 +1,7 @@ # -*- coding: utf-8 -*- -try: - import unittest2 as unittest -except ImportError: - import unittest import argparse +import unittest from parameterized import parameterized diff --git a/tests/test_createrepo_wrapper.py b/tests/test_createrepo_wrapper.py index 9d968bb2..a5513ffb 100644 --- a/tests/test_createrepo_wrapper.py +++ b/tests/test_createrepo_wrapper.py @@ -1,9 +1,6 @@ # -*- coding: utf-8 -*- -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import six diff --git a/tests/test_createrepophase.py b/tests/test_createrepophase.py index 3c2f2efa..7126d885 100644 --- a/tests/test_createrepophase.py +++ b/tests/test_createrepophase.py @@ -1,12 +1,8 @@ # -*- coding: utf-8 -*- -try: - import unittest2 as unittest -except ImportError: - import unittest - import glob import os +import unittest from unittest import mock import six diff --git a/tests/test_fus_wrapper.py b/tests/test_fus_wrapper.py index bfc2696b..1483ade5 100644 --- a/tests/test_fus_wrapper.py +++ b/tests/test_fus_wrapper.py @@ -1,9 +1,6 @@ # -*- coding: utf-8 -*- -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import tempfile from textwrap import dedent diff --git a/tests/test_gather.py b/tests/test_gather.py index 51fda80e..d97a4ee8 100644 --- a/tests/test_gather.py +++ b/tests/test_gather.py @@ -1,17 +1,12 @@ # -*- coding: utf-8 -*- -try: - import unittest2 as unittest -except ImportError: - import unittest - - +import logging import os -import tempfile import shutil import six import sys -import logging +import tempfile +import unittest from six.moves import cStringIO diff --git a/tests/test_gather_phase.py b/tests/test_gather_phase.py index 10d5db7d..08cbb442 100644 --- a/tests/test_gather_phase.py +++ b/tests/test_gather_phase.py @@ -6,10 +6,7 @@ import os from unittest import mock -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import six diff --git a/tests/test_gather_source_module.py b/tests/test_gather_source_module.py index a3482c3c..fd44a0ec 100644 --- a/tests/test_gather_source_module.py +++ b/tests/test_gather_source_module.py @@ -1,9 +1,6 @@ # -*- coding: utf-8 -*- -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from unittest import mock import six diff --git a/tests/test_graph.py b/tests/test_graph.py index 0ca9863f..2e2e847b 100644 --- a/tests/test_graph.py +++ b/tests/test_graph.py @@ -1,9 +1,6 @@ # -*- coding: utf-8 -*- -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from pungi.graph import SimpleAcyclicOrientedGraph diff --git a/tests/test_imagechecksumphase.py b/tests/test_imagechecksumphase.py index 26930989..50187324 100644 --- a/tests/test_imagechecksumphase.py +++ b/tests/test_imagechecksumphase.py @@ -1,14 +1,14 @@ # -*- coding: utf-8 -*- try: - import unittest2 as unittest + from unittest import mock except ImportError: - import unittest -from unittest import mock + import mock import os -import tempfile import shutil +import tempfile +import unittest from pungi.phases.image_checksum import ImageChecksumPhase, dump_checksums from tests.helpers import DummyCompose, PungiTestCase diff --git a/tests/test_initphase.py b/tests/test_initphase.py index 32989208..0edf37b4 100644 --- a/tests/test_initphase.py +++ b/tests/test_initphase.py @@ -1,11 +1,12 @@ # -*- coding: utf-8 -*- +import unittest + try: - import unittest2 as unittest + from unittest import mock except ImportError: - import unittest -from unittest import mock + import mock import six diff --git a/tests/test_iso_wrapper.py b/tests/test_iso_wrapper.py index 331fd632..8fec6438 100644 --- a/tests/test_iso_wrapper.py +++ b/tests/test_iso_wrapper.py @@ -4,11 +4,7 @@ import itertools from unittest import mock import os import six - -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from pungi.wrappers import iso diff --git a/tests/test_koji_wrapper.py b/tests/test_koji_wrapper.py index 1bedb0ba..7028a08f 100644 --- a/tests/test_koji_wrapper.py +++ b/tests/test_koji_wrapper.py @@ -3,10 +3,7 @@ import json from unittest import mock -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import tempfile import os diff --git a/tests/test_lorax_wrapper.py b/tests/test_lorax_wrapper.py index 3eb6f535..bdbc400a 100644 --- a/tests/test_lorax_wrapper.py +++ b/tests/test_lorax_wrapper.py @@ -1,9 +1,6 @@ # -*- coding: utf-8 -*- -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import six diff --git a/tests/test_media_split.py b/tests/test_media_split.py index eba600df..320f196a 100644 --- a/tests/test_media_split.py +++ b/tests/test_media_split.py @@ -1,10 +1,11 @@ # -*- coding: utf-8 -*- +import unittest + try: - import unittest2 as unittest + from unittest import mock except ImportError: - import unittest -from unittest import mock + import mock from pungi import media_split diff --git a/tests/test_module_util.py b/tests/test_module_util.py index 0d083af0..d879655c 100644 --- a/tests/test_module_util.py +++ b/tests/test_module_util.py @@ -1,9 +1,6 @@ import os -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from parameterized import parameterized from pungi import module_util diff --git a/tests/test_notifier.py b/tests/test_notifier.py index 750953d1..46645543 100644 --- a/tests/test_notifier.py +++ b/tests/test_notifier.py @@ -4,10 +4,7 @@ from datetime import datetime import json from unittest import mock -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from pungi.notifier import PungiNotifier diff --git a/tests/test_patch_iso.py b/tests/test_patch_iso.py index 381313ac..9927c0e5 100644 --- a/tests/test_patch_iso.py +++ b/tests/test_patch_iso.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- -from unittest import mock -import os - try: - import unittest2 as unittest + from unittest import mock except ImportError: - import unittest + import mock + +import os +import unittest from tests.helpers import boom, touch, copy_fixture from pungi_utils import patch_iso diff --git a/tests/test_phase_base.py b/tests/test_phase_base.py index 15a7f2d9..35491478 100644 --- a/tests/test_phase_base.py +++ b/tests/test_phase_base.py @@ -2,10 +2,7 @@ from unittest import mock -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import random import time diff --git a/tests/test_pkgset_pkgsets.py b/tests/test_pkgset_pkgsets.py index aed56126..135522be 100644 --- a/tests/test_pkgset_pkgsets.py +++ b/tests/test_pkgset_pkgsets.py @@ -5,10 +5,7 @@ from unittest import mock import os import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import json import tempfile import re diff --git a/tests/test_pkgset_source_koji.py b/tests/test_pkgset_source_koji.py index 0e55481d..7a952e53 100644 --- a/tests/test_pkgset_source_koji.py +++ b/tests/test_pkgset_source_koji.py @@ -1,14 +1,17 @@ # -*- coding: utf-8 -*- import json -import unittest -from unittest import mock + +try: + from unittest import mock +except ImportError: + import mock import os import re import six +import unittest from ddt import ddt, data, unpack from typing import AnyStr, List, Set, Dict, Tuple - from tests.test_gather_method_hybrid import MockModule from pungi.phases.pkgset.sources import source_koji, source_kojimock diff --git a/tests/test_repoclosure_phase.py b/tests/test_repoclosure_phase.py index 2cc61626..4fad10da 100644 --- a/tests/test_repoclosure_phase.py +++ b/tests/test_repoclosure_phase.py @@ -1,9 +1,6 @@ # -*- coding: utf-8 -*- -try: - from unittest import mock -except ImportError: - import mock +from unittest import mock import six import pungi.phases.repoclosure as repoclosure_phase diff --git a/tests/test_scm.py b/tests/test_scm.py index 8814027e..317ade2a 100644 --- a/tests/test_scm.py +++ b/tests/test_scm.py @@ -2,15 +2,12 @@ from unittest import mock -try: - import unittest2 as unittest -except ImportError: - import unittest +import os +import random import shutil import tempfile -import random +import unittest -import os import six from parameterized import parameterized diff --git a/tests/test_util.py b/tests/test_util.py index 4934bd18..3ecab4a3 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -4,10 +4,7 @@ import argparse from unittest import mock import os -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import tempfile import shutil import subprocess diff --git a/tests/test_variant_wrapper.py b/tests/test_variant_wrapper.py index 83f2d251..1a035f5e 100644 --- a/tests/test_variant_wrapper.py +++ b/tests/test_variant_wrapper.py @@ -1,9 +1,6 @@ # -*- coding: utf-8 -*- -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from six.moves import cStringIO from pungi.wrappers.variants import VariantsXmlParser