CentOS compatibility: fix tests
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Tue, 5 Mar 2013 15:49:56 +0000 (17:49 +0200)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Fri, 14 Nov 2014 12:46:24 +0000 (14:46 +0200)
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
14 files changed:
tests/01_test_help.py
tests/02_test_upstream_source_tar_unpack.py
tests/05_test_detection.py
tests/06_test_upstream_source.py
tests/08_test_patch.py
tests/11_test_dch_main.py
tests/12_test_deb.py
tests/13_test_gbp_pq.py
tests/16_test_supercommand.py
tests/18_test_Config.py
tests/19_test_gbp_scripts_config.py
tests/component/rpm/test_import_srpm.py
tests/test_import_orig.py
tests/testutils.py

index 6a4810bb0e6bbfb9b03430f2047417f39278f473..a421eb8d17d3d1337222a9403bfb3e4f70928b3e 100644 (file)
@@ -4,7 +4,11 @@
 
 from . import context
 
-import unittest
+# Try unittest2 for CentOS
+try:
+    import unittest2 as unittest
+except ImportError:
+    import unittest
 
 class TestHelp(unittest.TestCase):
     """Test help output of gbp commands"""
index 97bf76bbc22bac2a93183a8d474081daeb678dcb..e6147abd3250011814696b7c7f3b3698096e1cda 100644 (file)
@@ -8,7 +8,11 @@ import os
 import shutil
 import tarfile
 import tempfile
-import unittest
+# Try unittest2 for CentOS
+try:
+    import unittest2 as unittest
+except ImportError:
+    import unittest
 
 import gbp.pkg
 
index 126a299241c629834d3fa98424a8efddc5b2e8d7..c3f729bacf05086e2e12d53856bf3fe6c8310912 100644 (file)
@@ -4,7 +4,11 @@
 
 from . import context
 
-import unittest
+# Try unittest2 for CentOS
+try:
+    import unittest2 as unittest
+except ImportError:
+    import unittest
 
 from gbp.scripts import buildpackage
 from gbp.deb import (DebianPkgPolicy, orig_file)
index c6df6f14f6eaae3bdf4e14a745e3e662e2766995..6b2a1a1efdce930f96f95716dd20a678cd125297 100644 (file)
@@ -9,7 +9,11 @@ import os
 import shutil
 import tarfile
 import tempfile
-import unittest
+# Try unittest2 for CentOS
+try:
+    import unittest2 as unittest
+except ImportError:
+    import unittest
 import zipfile
 
 from gbp.pkg import UpstreamSource
index df1d43d4d4f8f5f60ded1e03a3293afdf25e611a..dd1532e21f81bb75676147b57b064ef34f1d6abe 100644 (file)
@@ -5,7 +5,11 @@
 from . import context
 
 import os
-import unittest
+# Try unittest2 for CentOS
+try:
+    import unittest2 as unittest
+except ImportError:
+    import unittest
 
 from gbp.patch_series import Patch
 
index dbfc25cd6dab31e1c044f6b20930139b607904a0..9bdc5c5b812b2330c68457a5ea14a5f3c436190a 100644 (file)
@@ -4,7 +4,11 @@
 
 from . import context
 
-import unittest
+# Try unittest2 for CentOS
+try:
+    import unittest2 as unittest
+except ImportError:
+    import unittest
 
 from tests.testutils import (DebianGitTestRepo, OsReleaseFile,
                              get_dch_default_urgency)
index d46f987c2597f88daa85d69efb3a6a88f572971b..2be30976d1efbd3b681dfabddd0c93fd9c0feb01 100644 (file)
@@ -4,7 +4,12 @@
 
 from . import context
 
-import os, tempfile, unittest
+import os, tempfile
+# Try unittest2 for CentOS
+try:
+    import unittest2 as unittest
+except ImportError:
+    import unittest
 
 import gbp.deb
 
index 1ae4b62a39d9d584b86827e58b138028f8b3c073..f71c5420e8d9d5b1b507efbcd5c8b36cd41ec17b 100644 (file)
@@ -19,7 +19,11 @@ from . import context
 
 import os
 import logging
-import unittest
+# Try unittest2 for CentOS
+try:
+    import unittest2 as unittest
+except ImportError:
+    import unittest
 
 from gbp.scripts.pq import generate_patches, switch_pq, export_patches
 import gbp.scripts.common.pq as pq
index f72bb5622f63c8fa358c92e5a590d3991ded4914..296ef8ed7d49121e8e9a68a20a392da82420b22c 100644 (file)
 """Test L{gbp} command wrapper"""
 
 import sys
-import unittest
+# Try unittest2 for CentOS
+try:
+    import unittest2 as unittest
+except ImportError:
+    import unittest
 import gbp.scripts.supercommand
 
 class TestSuperCommand(unittest.TestCase):
index f7ba8c9c629cb530b7a2fe82c09cfc2b5f9b6263..0bb7354e14d629c8ff5f0b2d4b2b9cdd25f71408 100644 (file)
@@ -1,7 +1,11 @@
 # vim: set fileencoding=utf-8 :
 
 import os
-import unittest
+# Try unittest2 for CentOS
+try:
+    import unittest2 as unittest
+except ImportError:
+    import unittest
 from gbp.config import GbpOptionParser, GbpOptionGroup
 from . import context
 
index f503ef54115e784e9ac52b4a736ad34b51dd724a..c984329aa6366454525daeee5f71e31ea8e09bb0 100644 (file)
 
 import os
 import sys
-import unittest
+# Try unittest2 for CentOS
+try:
+    import unittest2 as unittest
+except ImportError:
+    import unittest
 import gbp.scripts.config
 
 class TestGbpConfigCommand(unittest.TestCase):
index 5515707e05fc7bddf0a9d7ed96a0a08ea928adad..54898f7f50f58b463fdedbee758cf669c0fb9417 100644 (file)
@@ -54,8 +54,8 @@ class TestImportPacked(ComponentTestBase):
         eq_(mock_import(['--no-pristine-tar', srpm]), 0)
         # Check repository state
         repo = GitRepository('gbp-test')
-        files =  {'Makefile', 'README', 'bar.tar.gz', 'dummy.sh', 'foo.txt',
-                  'gbp-test.spec', 'my.patch', 'mydir/myfile.txt'}
+        files =  set(['Makefile', 'README', 'bar.tar.gz', 'dummy.sh', 'foo.txt',
+                  'gbp-test.spec', 'my.patch', 'mydir/myfile.txt'])
         self._check_repo_state(repo, 'master', ['master', 'upstream'], files)
         # Four commits: upstream, packaging files, one patch and the removal
         # of imported patches
@@ -67,9 +67,9 @@ class TestImportPacked(ComponentTestBase):
         eq_(mock_import(['--no-pristine-tar', srpm]), 0)
         # Check repository state
         repo = GitRepository('gbp-test2')
-        files = {'Makefile', 'README', 'bar.tar.gz', 'dummy.sh', 'foo.txt',
+        files = set(['Makefile', 'README', 'bar.tar.gz', 'dummy.sh', 'foo.txt',
                  'gbp-test2.spec', 'gbp-test2-alt.spec', 'my.patch',
-                 'mydir/myfile.txt'}
+                 'mydir/myfile.txt'])
         self._check_repo_state(repo, 'master', ['master', 'upstream'], files)
 
         # Four commits: upstream, packaging files, one patch and the removal
@@ -85,8 +85,8 @@ class TestImportPacked(ComponentTestBase):
         eq_(mock_import(['--no-pristine-tar', '--orphan-packaging', srpm]), 0)
         # Check repository state
         repo = GitRepository('gbp-test2')
-        files = {'bar.tar.gz', 'foo.txt', 'gbp-test2.spec',
-                 'gbp-test2-alt.spec', 'my.patch', 'my2.patch', 'my3.patch'}
+        files = set(['bar.tar.gz', 'foo.txt', 'gbp-test2.spec',
+                 'gbp-test2-alt.spec', 'my.patch', 'my2.patch', 'my3.patch'])
         self._check_repo_state(repo, 'master', ['master', 'upstream'], files)
         # Only one commit: the packaging files
         eq_(len(repo.get_commits()), 1)
@@ -96,8 +96,8 @@ class TestImportPacked(ComponentTestBase):
         srpm = os.path.join(DATA_DIR, 'gbp-test-native-1.0-1.src.rpm')
         eq_(mock_import(['--native', srpm]), 0)
         # Check repository state
-        files = {'.gbp.conf', 'Makefile', 'README', 'dummy.sh',
-                 'packaging/gbp-test-native.spec'}
+        files = set(['.gbp.conf', 'Makefile', 'README', 'dummy.sh',
+                 'packaging/gbp-test-native.spec'])
         repo = GitRepository('gbp-test-native')
         self._check_repo_state(repo, 'master', ['master'], files)
         # Only one commit: the imported source tarball
@@ -147,8 +147,8 @@ class TestImportPacked(ComponentTestBase):
         eq_(len(repo.get_commits(until='upstream')), 1)
         # Import new version
         eq_(mock_import(['--no-pristine-tar', srpms[2]]), 0)
-        files = {'Makefile', 'README', 'bar.tar.gz', 'dummy.sh', 'foo.txt',
-                 'gbp-test.spec', 'my.patch', 'mydir/myfile.txt'}
+        files = set(['Makefile', 'README', 'bar.tar.gz', 'dummy.sh', 'foo.txt',
+                 'gbp-test.spec', 'my.patch', 'mydir/myfile.txt'])
         self._check_repo_state(repo, 'master', ['master', 'upstream'], files)
         eq_(len(repo.get_commits()), 11)
         eq_(len(repo.get_commits(until='upstream')), 2)
@@ -214,10 +214,10 @@ class TestImportPacked(ComponentTestBase):
                     srpm]), 0)
         # Check repository state
         repo = GitRepository('gbp-test2')
-        files = {'Makefile', 'README', 'dummy.sh', 'packaging/bar.tar.gz',
+        files = set(['Makefile', 'README', 'dummy.sh', 'packaging/bar.tar.gz',
                  'packaging/foo.txt', 'packaging/gbp-test2.spec',
                  'packaging/gbp-test2-alt.spec', 'packaging/my.patch',
-                 'packaging/my2.patch', 'packaging/my3.patch'}
+                 'packaging/my2.patch', 'packaging/my3.patch'])
         self._check_repo_state(repo, 'pack', ['pack', 'orig'], files)
         eq_(len(repo.get_commits()), 2)
         # Check packaging dir
index d596d1dffea3b3f79a845f456f9fcfe9f856ca7c..aa39e38064bb533f88fb201aa0d10ccc64d1f7d9 100644 (file)
@@ -21,7 +21,11 @@ import glob
 import os
 import tarfile
 import tempfile
-import unittest
+# Try unittest2 for CentOS
+try:
+    import unittest2 as unittest
+except ImportError:
+    import unittest
 
 from gbp.errors import GbpError
 from gbp.pkg import UpstreamSource
index 6331e12d1a6b78e55ace901ccfbc49f36f9cb7f2..7cc7e361e80b59b0e26461cf14d4b838644cb84e 100644 (file)
@@ -7,7 +7,11 @@ import shutil
 import subprocess
 import tarfile
 import tempfile
-import unittest
+# Try unittest2 for CentOS
+try:
+    import unittest2 as unittest
+except ImportError:
+    import unittest
 import zipfile
 
 import gbp.log