From 9c3b74b1f84476eb1397295332a5d869d38437a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Mon, 6 Apr 2020 01:31:19 +0200 Subject: [PATCH] Build without unittest2 and mock - unittest2 is to be removed: https://bugzilla.redhat.com/show_bug.cgi?id=1794222 - mock is not used at all Merged upstream PR: https://github.com/redhat-performance/tuned/pull/249 --- 249.patch | 288 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tuned.spec | 14 ++- 2 files changed, 299 insertions(+), 3 deletions(-) create mode 100644 249.patch diff --git a/249.patch b/249.patch new file mode 100644 index 0000000..81cf04f --- /dev/null +++ b/249.patch @@ -0,0 +1,288 @@ +From 2399aa3b2de67e0d8134bc2964c63121e5c4173f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= +Date: Tue, 25 Feb 2020 19:59:25 +0100 +Subject: [PATCH] Remove usage of unittest2, use unittest from the standard + library + +Fixes https://github.com/redhat-performance/tuned/issues/241 + +Fedora is removing the unittest2 package: https://bugzilla.redhat.com/show_bug.cgi?id=1794222 + +tuned is not targeting Python 2.6: https://github.com/redhat-performance/tuned/issues/241#issuecomment-588320175 + +One thing not present in Python 2.7 is assertItemsEqual() -- renamed to assertCountEqual(). + +Related, mock was also listed as a requirement in the spec file, +but all the imports are from unittest.mock, hence removed. +--- + tests/unit/exports/test_controller.py | 4 ++-- + tests/unit/hardware/test_device_matcher.py | 4 ++-- + tests/unit/hardware/test_device_matcher_udev.py | 4 ++-- + tests/unit/hardware/test_inventory.py | 9 ++++++--- + tests/unit/monitors/test_base.py | 4 ++-- + tests/unit/plugins/test_base.py | 4 ++-- + tests/unit/profiles/test_loader.py | 4 ++-- + tests/unit/profiles/test_locator.py | 4 ++-- + tests/unit/profiles/test_merger.py | 4 ++-- + tests/unit/profiles/test_profile.py | 4 ++-- + tests/unit/profiles/test_unit.py | 4 ++-- + tests/unit/utils/test_commands.py | 4 ++-- + tests/unit/utils/test_global_config.py | 4 ++-- + tuned.spec | 2 +- + 14 files changed, 31 insertions(+), 28 deletions(-) + +diff --git a/tests/unit/exports/test_controller.py b/tests/unit/exports/test_controller.py +index af2e0176..333cff59 100644 +--- a/tests/unit/exports/test_controller.py ++++ b/tests/unit/exports/test_controller.py +@@ -1,10 +1,10 @@ +-import unittest2 ++import unittest + from unittest.mock import Mock + + from tuned.exports.controller import ExportsController + import tuned.exports as exports + +-class ControllerTestCase(unittest2.TestCase): ++class ControllerTestCase(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls._controller = ExportsController() +diff --git a/tests/unit/hardware/test_device_matcher.py b/tests/unit/hardware/test_device_matcher.py +index 1987eb66..d3e879f3 100644 +--- a/tests/unit/hardware/test_device_matcher.py ++++ b/tests/unit/hardware/test_device_matcher.py +@@ -1,7 +1,7 @@ +-import unittest2 ++import unittest + from tuned.hardware.device_matcher import DeviceMatcher + +-class DeviceMatcherTestCase(unittest2.TestCase): ++class DeviceMatcherTestCase(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls.matcher = DeviceMatcher() +diff --git a/tests/unit/hardware/test_device_matcher_udev.py b/tests/unit/hardware/test_device_matcher_udev.py +index 8e93428e..19039556 100644 +--- a/tests/unit/hardware/test_device_matcher_udev.py ++++ b/tests/unit/hardware/test_device_matcher_udev.py +@@ -1,9 +1,9 @@ +-import unittest2 ++import unittest + import pyudev + + from tuned.hardware.device_matcher_udev import DeviceMatcherUdev + +-class DeviceMatcherUdevTestCase(unittest2.TestCase): ++class DeviceMatcherUdevTestCase(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls.udev_context = pyudev.Context() +diff --git a/tests/unit/hardware/test_inventory.py b/tests/unit/hardware/test_inventory.py +index 00f8def0..f8a02402 100644 +--- a/tests/unit/hardware/test_inventory.py ++++ b/tests/unit/hardware/test_inventory.py +@@ -1,4 +1,4 @@ +-import unittest2 ++import unittest + from unittest.mock import Mock + import pyudev + +@@ -6,7 +6,7 @@ + + subsystem_name = "test subsystem" + +-class InventoryTestCase(unittest2.TestCase): ++class InventoryTestCase(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls._context = pyudev.Context() +@@ -25,7 +25,10 @@ def test_get_device(self): + def test_get_devices(self): + device_list1 = self._context.list_devices(subsystem = "tty") + device_list2 = self._inventory.get_devices("tty") +- self.assertItemsEqual(device_list1,device_list2) ++ try: ++ self.assertCountEqual(device_list1,device_list2) ++ except AttributeError: # Python 2 ++ self.assertItemsEqual(device_list1,device_list2) + + def test_subscribe(self): + self._inventory.subscribe(self._dummy,subsystem_name, +diff --git a/tests/unit/monitors/test_base.py b/tests/unit/monitors/test_base.py +index 2d6e82c7..8b45fdae 100644 +--- a/tests/unit/monitors/test_base.py ++++ b/tests/unit/monitors/test_base.py +@@ -1,4 +1,4 @@ +-import unittest2 ++import unittest + import tuned.monitors.base + + class MockMonitor(tuned.monitors.base.Monitor): +@@ -12,7 +12,7 @@ def update(cls): + cls._load.setdefault(device, 0) + cls._load[device] += 1 + +-class MonitorBaseClassTestCase(unittest2.TestCase): ++class MonitorBaseClassTestCase(unittest.TestCase): + def test_fail_base_class_init(self): + with self.assertRaises(NotImplementedError): + tuned.monitors.base.Monitor() +diff --git a/tests/unit/plugins/test_base.py b/tests/unit/plugins/test_base.py +index b49f98ec..fdbf6cf4 100644 +--- a/tests/unit/plugins/test_base.py ++++ b/tests/unit/plugins/test_base.py +@@ -3,7 +3,7 @@ + except ImportError: + from collections import Mapping + import tempfile +-import unittest2 ++import unittest + + from tuned.monitors.repository import Repository + import tuned.plugins.decorators as decorators +@@ -26,7 +26,7 @@ + storage_provider = storage.PickleProvider() + storage_factory = storage.Factory(storage_provider) + +-class PluginBaseTestCase(unittest2.TestCase): ++class PluginBaseTestCase(unittest.TestCase): + def setUp(self): + self._plugin = DummyPlugin(monitors_repository,storage_factory,\ + hardware_inventory,device_matcher,device_matcher_udev,\ +diff --git a/tests/unit/profiles/test_loader.py b/tests/unit/profiles/test_loader.py +index 1f4ed658..b6ea76e9 100644 +--- a/tests/unit/profiles/test_loader.py ++++ b/tests/unit/profiles/test_loader.py +@@ -1,4 +1,4 @@ +-import unittest2 ++import unittest + import tempfile + import shutil + import os +@@ -6,7 +6,7 @@ + import tuned.profiles as profiles + from tuned.profiles.exceptions import InvalidProfileException + +-class LoaderTestCase(unittest2.TestCase): ++class LoaderTestCase(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls._test_dir = tempfile.mkdtemp() +diff --git a/tests/unit/profiles/test_locator.py b/tests/unit/profiles/test_locator.py +index 6ab7c5ec..741abdc1 100644 +--- a/tests/unit/profiles/test_locator.py ++++ b/tests/unit/profiles/test_locator.py +@@ -1,10 +1,10 @@ +-import unittest2 ++import unittest + import os + import shutil + import tempfile + from tuned.profiles.locator import Locator + +-class LocatorTestCase(unittest2.TestCase): ++class LocatorTestCase(unittest.TestCase): + def setUp(self): + self.locator = Locator(self._tmp_load_dirs) + +diff --git a/tests/unit/profiles/test_merger.py b/tests/unit/profiles/test_merger.py +index 6023b26f..7b91d675 100644 +--- a/tests/unit/profiles/test_merger.py ++++ b/tests/unit/profiles/test_merger.py +@@ -1,9 +1,9 @@ +-import unittest2 ++import unittest + from tuned.profiles.merger import Merger + from tuned.profiles.profile import Profile + from collections import OrderedDict + +-class MergerTestCase(unittest2.TestCase): ++class MergerTestCase(unittest.TestCase): + def test_merge_without_replace(self): + merger = Merger() + config1 = OrderedDict([ +diff --git a/tests/unit/profiles/test_profile.py b/tests/unit/profiles/test_profile.py +index 8f43e3d2..e5c85c94 100644 +--- a/tests/unit/profiles/test_profile.py ++++ b/tests/unit/profiles/test_profile.py +@@ -1,4 +1,4 @@ +-import unittest2 ++import unittest + import tuned.profiles + import collections + +@@ -6,7 +6,7 @@ class MockProfile(tuned.profiles.profile.Profile): + def _create_unit(self, name, config): + return (name, config) + +-class ProfileTestCase(unittest2.TestCase): ++class ProfileTestCase(unittest.TestCase): + + def test_init(self): + MockProfile("test", {}) +diff --git a/tests/unit/profiles/test_unit.py b/tests/unit/profiles/test_unit.py +index 34bfd0a5..d63ff0c1 100644 +--- a/tests/unit/profiles/test_unit.py ++++ b/tests/unit/profiles/test_unit.py +@@ -1,7 +1,7 @@ +-import unittest2 ++import unittest + from tuned.profiles import Unit + +-class UnitTestCase(unittest2.TestCase): ++class UnitTestCase(unittest.TestCase): + + def test_default_options(self): + unit = Unit("sample", {}) +diff --git a/tests/unit/utils/test_commands.py b/tests/unit/utils/test_commands.py +index 09502036..d63556ee 100644 +--- a/tests/unit/utils/test_commands.py ++++ b/tests/unit/utils/test_commands.py +@@ -1,4 +1,4 @@ +-import unittest2 ++import unittest + import tempfile + import shutil + import re +@@ -9,7 +9,7 @@ + from tuned.exceptions import TunedException + import tuned.utils.commands + +-class CommandsTestCase(unittest2.TestCase): ++class CommandsTestCase(unittest.TestCase): + def setUp(self): + self._commands = commands() + self._test_dir = tempfile.mkdtemp() +diff --git a/tests/unit/utils/test_global_config.py b/tests/unit/utils/test_global_config.py +index d2a98895..5b93888c 100644 +--- a/tests/unit/utils/test_global_config.py ++++ b/tests/unit/utils/test_global_config.py +@@ -1,4 +1,4 @@ +-import unittest2 ++import unittest + import tempfile + import shutil + import os +@@ -6,7 +6,7 @@ + import tuned.consts as consts + import tuned.utils.global_config as global_config + +-class GlobalConfigTestCase(unittest2.TestCase): ++class GlobalConfigTestCase(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls.test_dir = tempfile.mkdtemp() +diff --git a/tuned.spec b/tuned.spec +index 618d42d5..ba8d5f97 100644 +--- a/tuned.spec ++++ b/tuned.spec +@@ -60,7 +60,7 @@ Requires(preun): systemd + Requires(postun): systemd + BuildRequires: %{_py}, %{_py}-devel + # BuildRequires for 'make test' +-BuildRequires: %{_py}-unittest2, %{_py}-configobj, %{_py}-mock ++BuildRequires: %{_py}-configobj + BuildRequires: %{_py}-decorator, %{_py}-pyudev + Requires: %{_py}-decorator, %{_py}-pyudev, %{_py}-configobj + Requires: %{_py}-schedutils, %{_py}-linux-procfs, %{_py}-perf diff --git a/tuned.spec b/tuned.spec index 1e4c38d..e2f06a7 100644 --- a/tuned.spec +++ b/tuned.spec @@ -34,9 +34,14 @@ Summary: A dynamic adaptive system tuning daemon Name: tuned Version: 2.13.0 -Release: 2%{?prerel1}%{?dist} +Release: 3%{?prerel1}%{?dist} License: GPLv2+ Source0: https://github.com/redhat-performance/%{name}/archive/v%{version}%{?prerel2}/%{name}-%{version}%{?prerel2}.tar.gz + +# Remove usage of unittest2, use unittest from the standard library +# Merged upstream +Patch1: https://github.com/redhat-performance/tuned/pull/249.patch + URL: http://www.tuned-project.org/ BuildArch: noarch BuildRequires: systemd, desktop-file-utils @@ -50,7 +55,7 @@ Requires(preun): systemd Requires(postun): systemd BuildRequires: %{_py}, %{_py}-devel # BuildRequires for 'make test' -BuildRequires: %{_py}-unittest2, %{_py}-configobj, %{_py}-mock +BuildRequires: %{_py}-configobj BuildRequires: %{_py}-decorator, %{_py}-pyudev Requires: %{_py}-decorator, %{_py}-pyudev, %{_py}-configobj Requires: %{_py}-schedutils, %{_py}-linux-procfs, %{_py}-perf @@ -221,7 +226,7 @@ Additional tuned profiles mainly for backward compatibility with tuned 1.0. It can be also used to fine tune your system for specific scenarios. %prep -%setup -q -n %{name}-%{version}%{?prerel2} +%autosetup -p1 -n %{name}-%{version}%{?prerel2} %build # Docs cannot be generated on RHEL now due to missing asciidoctor dependency @@ -476,6 +481,9 @@ fi %{_mandir}/man7/tuned-profiles-compat.7* %changelog +* Mon Apr 06 2020 Miro HronĨok - 2.13.0-3 +- Build without unittest2 + * Fri Jan 31 2020 Fedora Release Engineering - 2.13.0-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild