summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2013-03-05 17:49:56 +0200
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>2013-04-03 10:11:41 +0300
commitf4b662204cf84ce0d3fd2165aa96ed4385e46a71 (patch)
treed4ae5c1cbe632150f7bf47e3239425e6f99b713a
parent86a66af33b841bd9c4638be12cf254143c6fa55b (diff)
downloadgit-buildpackage-f4b662204cf84ce0d3fd2165aa96ed4385e46a71.tar.gz
git-buildpackage-f4b662204cf84ce0d3fd2165aa96ed4385e46a71.tar.bz2
git-buildpackage-f4b662204cf84ce0d3fd2165aa96ed4385e46a71.zip
CentOS compatibility: fix tests
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
-rw-r--r--tests/01_test_help.py6
-rw-r--r--tests/05_test_detection.py6
-rw-r--r--tests/06_test_upstream_source.py6
-rw-r--r--tests/08_test_patch.py6
-rw-r--r--tests/11_test_dch_main.py7
-rw-r--r--tests/12_test_deb.py7
-rw-r--r--tests/13_test_gbp_pq.py6
-rw-r--r--tests/component/rpm/test_import_srpm.py24
-rw-r--r--tests/test_rpm.py6
-rw-r--r--tests/testutils.py6
10 files changed, 57 insertions, 23 deletions
diff --git a/tests/01_test_help.py b/tests/01_test_help.py
index 9de8820e..718aaa78 100644
--- a/tests/01_test_help.py
+++ b/tests/01_test_help.py
@@ -2,7 +2,11 @@
"""Check if --help works"""
-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"""
diff --git a/tests/05_test_detection.py b/tests/05_test_detection.py
index 9abb6fe1..c4c22e6f 100644
--- a/tests/05_test_detection.py
+++ b/tests/05_test_detection.py
@@ -5,7 +5,11 @@
import os
import shutil
import tempfile
-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)
diff --git a/tests/06_test_upstream_source.py b/tests/06_test_upstream_source.py
index 7cc25fc7..0dbeb128 100644
--- a/tests/06_test_upstream_source.py
+++ b/tests/06_test_upstream_source.py
@@ -7,7 +7,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
diff --git a/tests/08_test_patch.py b/tests/08_test_patch.py
index 9816074b..89fd1fe4 100644
--- a/tests/08_test_patch.py
+++ b/tests/08_test_patch.py
@@ -3,7 +3,11 @@
"""Test L{Patch} class"""
import os
-import unittest
+# Try unittest2 for CentOS
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
from gbp.patch_series import Patch
diff --git a/tests/11_test_dch_main.py b/tests/11_test_dch_main.py
index 6ad08f82..f25fcc8b 100644
--- a/tests/11_test_dch_main.py
+++ b/tests/11_test_dch_main.py
@@ -2,8 +2,11 @@
"""Test L{gbp.scripts.dch} main"""
-import unittest
-
+# Try unittest2 for CentOS
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
from tests.testutils import DebianGitTestRepo
from gbp.scripts import dch
diff --git a/tests/12_test_deb.py b/tests/12_test_deb.py
index 12831a9d..990a7623 100644
--- a/tests/12_test_deb.py
+++ b/tests/12_test_deb.py
@@ -2,7 +2,12 @@
"""Test L{gbp.deb}"""
-import os, tempfile, unittest
+import os, tempfile
+# Try unittest2 for CentOS
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
import gbp.deb
from gbp.command_wrappers import CommandExecFailed
diff --git a/tests/13_test_gbp_pq.py b/tests/13_test_gbp_pq.py
index aeb6abfa..400ba5d1 100644
--- a/tests/13_test_gbp_pq.py
+++ b/tests/13_test_gbp_pq.py
@@ -17,7 +17,11 @@
import os
import logging
-import unittest
+# Try unittest2 for CentOS
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
import gbp.scripts.common.pq as pq
import gbp.patch_series
diff --git a/tests/component/rpm/test_import_srpm.py b/tests/component/rpm/test_import_srpm.py
index 1a9d0c68..c1bb35e0 100644
--- a/tests/component/rpm/test_import_srpm.py
+++ b/tests/component/rpm/test_import_srpm.py
@@ -46,8 +46,8 @@ class TestImportPacked(ComponentTestBase):
assert import_srpm(['arg0', 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/', 'mydir/myfile.txt'}
+ files = set(['Makefile', 'README', 'bar.tar.gz', 'dummy.sh', 'foo.txt',
+ 'gbp-test.spec', 'my.patch', 'mydir/', '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
@@ -59,9 +59,9 @@ class TestImportPacked(ComponentTestBase):
assert import_srpm(['arg0', 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/',
- '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
@@ -77,8 +77,8 @@ class TestImportPacked(ComponentTestBase):
assert import_srpm(['arg0', '--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
assert len(repo.get_commits()) == 1
@@ -88,8 +88,8 @@ class TestImportPacked(ComponentTestBase):
srpm = os.path.join(DATA_DIR, 'gbp-test-native-1.0-1.src.rpm')
assert import_srpm(['arg0', '--native', srpm]) == 0
# Check repository state
- files = {'.gbp.conf', 'Makefile', 'README', 'dummy.sh', 'packaging/',
- 'packaging/gbp-test-native.spec'}
+ files = set(['.gbp.conf', 'Makefile', 'README', 'dummy.sh', 'packaging/',
+ '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
@@ -124,8 +124,8 @@ class TestImportPacked(ComponentTestBase):
assert len(repo.get_commits(until='upstream')) == 1
# Import new version
assert import_srpm(['arg0', srpms[2]]) == 0
- files = {'Makefile', 'README', 'bar.tar.gz', 'dummy.sh', 'foo.txt',
- 'gbp-test.spec', 'my.patch', 'mydir/', 'mydir/myfile.txt'}
+ files = set(['Makefile', 'README', 'bar.tar.gz', 'dummy.sh', 'foo.txt',
+ 'gbp-test.spec', 'my.patch', 'mydir/', 'mydir/myfile.txt'])
self._check_repo_state(repo, 'master', ['master', 'upstream'], files)
assert len(repo.get_commits()) == 11
assert len(repo.get_commits(until='upstream')) == 2
@@ -182,11 +182,11 @@ class TestImportPacked(ComponentTestBase):
srpm]) == 0
# Check repository state
repo = GitRepository('gbp-test2')
- files = {'Makefile', 'README', 'dummy.sh', 'packaging/',
+ files = set(['Makefile', 'README', 'dummy.sh', 'packaging/',
'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/my3.patch'])
self._check_repo_state(repo, 'pack', ['pack', 'orig'], files)
assert len(repo.get_commits()) == 2
# Check packaging dir
diff --git a/tests/test_rpm.py b/tests/test_rpm.py
index f6469c4b..9d5a49bb 100644
--- a/tests/test_rpm.py
+++ b/tests/test_rpm.py
@@ -251,8 +251,10 @@ class TestSpecFile(object):
(name, val['value'], rval))
assert spec.ignorepatches == []
# Check patch numbers and patch filenames
- patches = {patch['num']: patch['linevalue'] for patch in
- spec.protected('_tags')['patch']['lines']}
+ patches = {}
+ for patch in spec.protected('_tags')['patch']['lines']:
+ patches[patch['num']] = patch['linevalue']
+
assert patches == {0: 'my_patch0', -1: 'my_patch'}
def test_patch_series(self):
diff --git a/tests/testutils.py b/tests/testutils.py
index ff20e090..e694c44d 100644
--- a/tests/testutils.py
+++ b/tests/testutils.py
@@ -2,7 +2,11 @@
import os
import shutil
-import unittest
+# Try unittest2 for CentOS
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
import gbp.log
import gbp.deb.git