diff --git a/pungi/wrappers/variants.py b/pungi/wrappers/variants.py index 87da5d5b..a57daaf3 100755 --- a/pungi/wrappers/variants.py +++ b/pungi/wrappers/variants.py @@ -17,7 +17,6 @@ from __future__ import print_function import os import copy import lxml.etree -from functools import total_ordering def get_variants_dtd(logger=None): @@ -207,7 +206,6 @@ class VariantsXmlParser(object): return result -@total_ordering class Variant(object): def __init__(self, id, name, type, arches, groups, environments=None, buildinstallpackages=None, is_empty=False, parent=None, @@ -257,6 +255,15 @@ class Variant(object): ORDERING = {'variant': 0, 'addon': 1, 'layered-product': 1, 'optional': 2} return (ORDERING[self.type], self.uid) < (ORDERING[other.type], other.uid) + def __le__(self, other): + return self < other or self == other + + def __gt__(self, other): + return not (self <= other) + + def __ge__(self, other): + return not (self < other) + def __hash__(self): return hash((self.type, self.uid)) diff --git a/tests/test_arguments.py b/tests/test_arguments.py index 074aded5..6438b2a0 100644 --- a/tests/test_arguments.py +++ b/tests/test_arguments.py @@ -1,5 +1,8 @@ import mock -import unittest +try: + import unittest2 as unittest +except ImportError: + import unittest import six from tests.helpers import load_bin diff --git a/tests/test_comps_wrapper.py b/tests/test_comps_wrapper.py index f0dd804e..48d91fa1 100644 --- a/tests/test_comps_wrapper.py +++ b/tests/test_comps_wrapper.py @@ -37,15 +37,15 @@ class CompsWrapperTest(unittest.TestCase): def test_get_groups(self): comps = CompsWrapper(COMPS_FILE) - self.assertItemsEqual( - comps.get_comps_groups(), - ['core', 'standard', 'text-internet', 'firefox', 'resilient-storage', 'basic-desktop']) + self.assertEqual( + sorted(comps.get_comps_groups()), + sorted(['core', 'standard', 'text-internet', 'firefox', 'resilient-storage', 'basic-desktop'])) def test_get_packages(self): comps = CompsWrapper(COMPS_FILE) - self.assertItemsEqual( - comps.get_packages('text-internet'), - {'dummy-elinks', 'dummy-tftp'}) + self.assertEqual( + sorted(comps.get_packages('text-internet')), + sorted(['dummy-elinks', 'dummy-tftp'])) def test_get_packages_for_non_existing_group(self): comps = CompsWrapper(COMPS_FILE) diff --git a/tests/test_gather_source_module.py b/tests/test_gather_source_module.py index e8736e0b..e656f875 100644 --- a/tests/test_gather_source_module.py +++ b/tests/test_gather_source_module.py @@ -1,9 +1,13 @@ # -*- coding: utf-8 -*- +try: + import unittest2 as unittest +except ImportError: + import unittest + import mock import os import sys -import unittest sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) diff --git a/tests/test_iso_wrapper.py b/tests/test_iso_wrapper.py index 7ebc2c3e..7bf37a61 100644 --- a/tests/test_iso_wrapper.py +++ b/tests/test_iso_wrapper.py @@ -3,7 +3,7 @@ import mock import os import sys -import unittest +import unittest2 as unittest import itertools sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) @@ -36,11 +36,11 @@ class TestIsoUtils(unittest.TestCase): def test_get_implanted_md5_incorrect(self, mock_run): mock_run.return_value = (0, INCORRECT_OUTPUT) logger = mock.Mock() - self.assertIsNone(iso.get_implanted_md5('dummy.iso', logger=logger)) + self.assertEqual(iso.get_implanted_md5('dummy.iso', logger=logger), None) self.assertEqual(mock_run.call_args_list, [mock.call(['/usr/bin/checkisomd5', '--md5sumonly', 'dummy.iso'], universal_newlines=True)]) - self.assertGreater(len(logger.mock_calls), 0) + self.assertTrue(len(logger.mock_calls) > 0) @mock.patch('pungi.util.run_unmount_cmd') @mock.patch('pungi.wrappers.iso.run') diff --git a/tests/test_notifier.py b/tests/test_notifier.py index ade3b048..9f334304 100644 --- a/tests/test_notifier.py +++ b/tests/test_notifier.py @@ -92,7 +92,7 @@ class TestNotifier(unittest.TestCase): n.send('cmd', **self.data) makedirs.assert_called_once_with('/logs/notifications') - self.assertItemsEqual(run.call_args_list, [self._call('run-notify', 'cmd')]) + self.assertEqual(run.call_args_list, [self._call('run-notify', 'cmd')]) @mock.patch('pungi.util.translate_path') @mock.patch('kobo.shortcuts.run') @@ -104,10 +104,10 @@ class TestNotifier(unittest.TestCase): n.compose = self.compose n.send('cmd', **self.data) - self.assertItemsEqual( - run.call_args_list, - [self._call('run-notify', 'cmd'), - self._call('ping-user', 'cmd')]) + self.assertEqual( + sorted(run.call_args_list), + sorted([self._call('run-notify', 'cmd'), + self._call('ping-user', 'cmd')])) @mock.patch('kobo.shortcuts.run') def test_translates_path(self, run, makedirs): @@ -120,7 +120,7 @@ class TestNotifier(unittest.TestCase): n.compose = self.compose n.send('cmd', **self.data) - self.assertItemsEqual( + self.assertEqual( run.call_args_list, [self._call('run-notify', 'cmd', location='http://example.com/compose/a/b')]) @@ -140,7 +140,7 @@ class TestNotifier(unittest.TestCase): n.compose = self.compose n.send('cmd', **self.data) - self.assertItemsEqual(run.call_args_list, [self._call('run-notify', 'cmd')]) + self.assertEqual(run.call_args_list, [self._call('run-notify', 'cmd')]) self.assertTrue(self.compose.log_warning.called) diff --git a/tests/test_pkgset_source_koji.py b/tests/test_pkgset_source_koji.py index fcd8710a..7450a903 100644 --- a/tests/test_pkgset_source_koji.py +++ b/tests/test_pkgset_source_koji.py @@ -4,7 +4,7 @@ import mock import os import sys -import unittest +import unittest2 as unittest import json import re