Skip to content

Commit

Permalink
Merge pull request #249 from hroncok/no-unittest2
Browse files Browse the repository at this point in the history
Remove usage of unittest2, use unittest from the standard library
  • Loading branch information
yarda committed Mar 31, 2020
2 parents 15a34ee + 2399aa3 commit 595b8e0
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 28 deletions.
4 changes: 2 additions & 2 deletions 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()
Expand Down
4 changes: 2 additions & 2 deletions 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()
Expand Down
4 changes: 2 additions & 2 deletions 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()
Expand Down
9 changes: 6 additions & 3 deletions tests/unit/hardware/test_inventory.py
@@ -1,12 +1,12 @@
import unittest2
import unittest
from unittest.mock import Mock
import pyudev

from tuned.hardware.inventory import Inventory

subsystem_name = "test subsystem"

class InventoryTestCase(unittest2.TestCase):
class InventoryTestCase(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls._context = pyudev.Context()
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/monitors/test_base.py
@@ -1,4 +1,4 @@
import unittest2
import unittest
import tuned.monitors.base

class MockMonitor(tuned.monitors.base.Monitor):
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/plugins/test_base.py
Expand Up @@ -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
Expand All @@ -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,\
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/profiles/test_loader.py
@@ -1,12 +1,12 @@
import unittest2
import unittest
import tempfile
import shutil
import os

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()
Expand Down
4 changes: 2 additions & 2 deletions 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)

Expand Down
4 changes: 2 additions & 2 deletions 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([
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/profiles/test_profile.py
@@ -1,12 +1,12 @@
import unittest2
import unittest
import tuned.profiles
import collections

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", {})
Expand Down
4 changes: 2 additions & 2 deletions 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", {})
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/utils/test_commands.py
@@ -1,4 +1,4 @@
import unittest2
import unittest
import tempfile
import shutil
import re
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/utils/test_global_config.py
@@ -1,12 +1,12 @@
import unittest2
import unittest
import tempfile
import shutil
import os

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()
Expand Down
2 changes: 1 addition & 1 deletion tuned.spec
Expand Up @@ -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
Expand Down

0 comments on commit 595b8e0

Please sign in to comment.