From 9a46acb2796b86d8aaa34649c126d951143b67f5 Mon Sep 17 00:00:00 2001
From: Lubomír Sedlář <lsedlar@redhat.com>
Date: Oct 03 2019 12:12:35 +0000
Subject: Drop unittest2 on Python 3


Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>

---

diff --git a/tests/test_changelog.py b/tests/test_changelog.py
index c5b4603..3ee3e1c 100644
--- a/tests/test_changelog.py
+++ b/tests/test_changelog.py
@@ -94,10 +94,10 @@ class ChangelogTest(unittest.TestCase):
         data = changelog.get_changelog(old_compose, new_compose)
         self.assertEqual(data['old_compose'], 'DP-1.0-20160315.t.0')
         self.assertEqual(data['new_compose'], 'DP-1.0-20160315.t.1')
-        self.assertItemsEqual(data['added_packages'], [DUMMY_ELINKS])
-        self.assertItemsEqual(data['dropped_packages'], [DUMMY_TFTP])
-        self.assertItemsEqual(data['upgraded_packages'], [DUMMY_FIREFOX])
-        self.assertItemsEqual(data['downgraded_packages'], [])
+        six.assertCountEqual(self, data['added_packages'], [DUMMY_ELINKS])
+        six.assertCountEqual(self, data['dropped_packages'], [DUMMY_TFTP])
+        six.assertCountEqual(self, data['upgraded_packages'], [DUMMY_FIREFOX])
+        six.assertCountEqual(self, data['downgraded_packages'], [])
         self.assertDictEqual(data['added_images'][0], {
             "arch": "s390x",
             "bootable": False,
diff --git a/tests/test_copy_compose.py b/tests/test_copy_compose.py
index 6231751..007b04c 100644
--- a/tests/test_copy_compose.py
+++ b/tests/test_copy_compose.py
@@ -6,6 +6,7 @@ except ImportError:
     import unittest
 import mock
 import os
+import six
 from six import StringIO
 import tempfile
 import shutil
@@ -34,7 +35,8 @@ class ChangelogTest(unittest.TestCase):
     @mock.patch('kobo.shortcuts.run')
     def test_copy_full(self, mock_run):
         copy_compose(self.compose, self.dest, variants=[], arches=[])
-        self.assertItemsEqual(
+        six.assertCountEqual(
+            self,
             mock_run.mock_calls,
             [mock.call(['rsync', '-avHh',
                         self.compose.compose_path + '/Client',
@@ -47,7 +49,8 @@ class ChangelogTest(unittest.TestCase):
     def test_copy_full_variant_from_explicit_path(self, mock_run):
         self.compose = get_compose(get_compose_path('DP-1.0-20160315.t.0') + '/compose/')
         copy_compose(self.compose, self.dest, variants=['Server'], arches=[])
-        self.assertItemsEqual(
+        six.assertCountEqual(
+            self,
             mock_run.mock_calls,
             [mock.call(['rsync', '-avHh',
                         os.path.join(self.compose.compose_path, 'Server'),
@@ -59,7 +62,8 @@ class ChangelogTest(unittest.TestCase):
     def test_copy_to_missing_dir(self, mock_run):
         self.dest = os.path.join(self.dest, 'missing', 'directory') + '/'
         copy_compose(self.compose, self.dest, variants=[], arches=[])
-        self.assertItemsEqual(
+        six.assertCountEqual(
+            self,
             mock_run.mock_calls,
             [mock.call(['rsync', '-avHh',
                         self.compose.compose_path + '/Client',
@@ -71,7 +75,8 @@ class ChangelogTest(unittest.TestCase):
     @mock.patch('kobo.shortcuts.run')
     def test_copy_full_with_extra_opts(self, mock_run):
         copy_compose(self.compose, self.dest, variants=[], arches=[], rsync_opts=['--exclude=repodata'])
-        self.assertItemsEqual(
+        six.assertCountEqual(
+            self,
             mock_run.mock_calls,
             [mock.call(['rsync', '-avHh', '--exclude=repodata',
                         self.compose.compose_path + '/Client',
@@ -83,7 +88,8 @@ class ChangelogTest(unittest.TestCase):
     @mock.patch('kobo.shortcuts.run')
     def test_copy_one_variant(self, mock_run):
         copy_compose(self.compose, self.dest, variants=['Client'], arches=[])
-        self.assertItemsEqual(
+        six.assertCountEqual(
+            self,
             mock_run.mock_calls,
             [mock.call(['rsync', '-avHh',
                         self.compose.compose_path + '/Client', self.dest],
@@ -94,7 +100,8 @@ class ChangelogTest(unittest.TestCase):
     def test_copy_one_arch_in_single_variant(self, mock_run):
         # Only client has i386
         copy_compose(self.compose, self.dest, variants=[], arches=['i386'])
-        self.assertItemsEqual(
+        six.assertCountEqual(
+            self,
             mock_run.mock_calls,
             [mock.call(['rsync', '-avHh',
                         self.compose.compose_path + '/Client/i386',
@@ -105,7 +112,8 @@ class ChangelogTest(unittest.TestCase):
     @mock.patch('kobo.shortcuts.run')
     def test_copy_source_in_single_variant(self, mock_run):
         copy_compose(self.compose, self.dest, variants=['Client'], arches=['src'])
-        self.assertItemsEqual(
+        six.assertCountEqual(
+            self,
             mock_run.mock_calls,
             [mock.call(['rsync', '-avHh',
                         self.compose.compose_path + '/Client/source',
@@ -117,7 +125,8 @@ class ChangelogTest(unittest.TestCase):
     def test_copy_one_arch_in_both_variants(self, mock_run):
         # Both Client and Server have x86_64
         copy_compose(self.compose, self.dest, variants=[], arches=['x86_64'])
-        self.assertItemsEqual(
+        six.assertCountEqual(
+            self,
             mock_run.mock_calls,
             [mock.call(['rsync', '-avHh',
                         self.compose.compose_path + '/Client/x86_64',
@@ -132,7 +141,8 @@ class ChangelogTest(unittest.TestCase):
     @mock.patch('kobo.shortcuts.run')
     def test_copy_one_arch_in_one_variant_with_filter(self, mock_run):
         copy_compose(self.compose, self.dest, variants=['Client'], arches=['x86_64'])
-        self.assertItemsEqual(
+        six.assertCountEqual(
+            self,
             mock_run.mock_calls,
             [mock.call(['rsync', '-avHh',
                         self.compose.compose_path + '/Client/x86_64',
@@ -143,7 +153,8 @@ class ChangelogTest(unittest.TestCase):
     @mock.patch('kobo.shortcuts.run')
     def test_copy_source_in_both_variants(self, mock_run):
         copy_compose(self.compose, self.dest, variants=[], arches=['src'])
-        self.assertItemsEqual(
+        six.assertCountEqual(
+            self,
             mock_run.mock_calls,
             [mock.call(['rsync', '-avHh',
                         self.compose.compose_path + '/Client/source',
@@ -158,7 +169,8 @@ class ChangelogTest(unittest.TestCase):
     @mock.patch('kobo.shortcuts.run')
     def test_copy_source_in_one_variant_with_filter(self, mock_run):
         copy_compose(self.compose, self.dest, variants=['Client'], arches=['src'])
-        self.assertItemsEqual(
+        six.assertCountEqual(
+            self,
             mock_run.mock_calls,
             [mock.call(['rsync', '-avHh',
                         self.compose.compose_path + '/Client/source',
@@ -172,7 +184,8 @@ class ChangelogTest(unittest.TestCase):
             copy_compose(self.compose, self.dest, variants=[], arches=[], dry_run=True)
 
         self.assertEqual(mock_run.mock_calls, [])
-        self.assertItemsEqual(
+        six.assertCountEqual(
+            self,
             out.getvalue().strip().split('\n'),
             [' '.join(['rsync', '-avHh',
                        self.compose.compose_path + '/Client',
@@ -186,7 +199,8 @@ class ChangelogTest(unittest.TestCase):
             copy_compose(self.compose, self.dest, variants=['Client'], arches=[], dry_run=True)
 
         self.assertEqual(mock_run.mock_calls, [])
-        self.assertItemsEqual(
+        six.assertCountEqual(
+            self,
             out.getvalue().strip().split('\n'),
             [' '.join(['rsync', '-avHh',
                        self.compose.compose_path + '/Client', self.dest])])
@@ -199,7 +213,8 @@ class ChangelogTest(unittest.TestCase):
             copy_compose(self.compose, self.dest, variants=[], arches=['i386'], dry_run=True)
 
         self.assertEqual(mock_run.mock_calls, [])
-        self.assertItemsEqual(
+        six.assertCountEqual(
+            self,
             out.getvalue().strip().split('\n'),
             [' '.join(['rsync', '-avHh',
                        self.compose.compose_path + '/Client/i386',
@@ -212,7 +227,8 @@ class ChangelogTest(unittest.TestCase):
             copy_compose(self.compose, self.dest, variants=[], arches=['x86_64'], dry_run=True)
 
         self.assertEqual(mock_run.mock_calls, [])
-        self.assertItemsEqual(
+        six.assertCountEqual(
+            self,
             out.getvalue().strip().split('\n'),
             [' '.join(['rsync', '-avHh',
                        self.compose.compose_path + '/Client/x86_64',
diff --git a/tests/test_find_latest.py b/tests/test_find_latest.py
index 7a4783d..6e26587 100644
--- a/tests/test_find_latest.py
+++ b/tests/test_find_latest.py
@@ -1,5 +1,7 @@
 import os
+
 import mock
+import six
 
 try:
     import unittest2 as unittest
@@ -23,12 +25,12 @@ class TestFindComposes(unittest.TestCase):
     def test_find_in_path(self):
         path = os.path.join(os.path.dirname(__file__), "composes")
         composes = find_latest.find_composes([path])
-        self.assertItemsEqual([c.info.compose.id for c in composes], EXISTING_COMPOSES)
+        six.assertCountEqual(self, [c.info.compose.id for c in composes], EXISTING_COMPOSES)
 
     def test_find_with_glob(self):
         path = os.path.join(os.path.dirname(__file__), "comp*")
         composes = find_latest.find_composes([path])
-        self.assertItemsEqual([c.info.compose.id for c in composes], EXISTING_COMPOSES)
+        six.assertCountEqual(self, [c.info.compose.id for c in composes], EXISTING_COMPOSES)
 
 
 class MockCI(object):
diff --git a/tox.ini b/tox.ini
index c8c9522..ef31b5a 100644
--- a/tox.ini
+++ b/tox.ini
@@ -9,7 +9,6 @@ deps=
   pytest-cov
   mock
   freezegun
-  unittest2
   koji
   kobo>=0.10.0
 setenv =
@@ -21,6 +20,11 @@ commands=
   --junitxml {toxworkdir}/junit.{envname}.xml \
   {posargs:.}
 
+[testenv:py27]
+deps =
+    {[testenv]deps}
+    unittest2
+
 [testenv:coverage]
 skip_install = true
 deps =

