From 5c61b78350858aab9f4ba2e088601d60bd81dbd8 Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Tue, 5 Mar 2013 17:49:56 +0200 Subject: CentOS compatibility: fix tests Signed-off-by: Markus Lehtonen --- tests/01_test_help.py | 6 +++++- tests/02_test_upstream_source_tar_unpack.py | 6 +++++- tests/05_test_detection.py | 6 +++++- tests/06_test_upstream_source.py | 6 +++++- tests/08_test_patch.py | 6 +++++- tests/11_test_dch_main.py | 6 +++++- tests/12_test_deb.py | 7 ++++++- tests/13_test_gbp_pq.py | 6 +++++- tests/16_test_supercommand.py | 6 +++++- tests/component/rpm/test_import_srpm.py | 24 ++++++++++++------------ tests/test_import_orig.py | 6 +++++- tests/test_rpm.py | 6 ++++-- tests/testutils.py | 6 +++++- 13 files changed, 72 insertions(+), 25 deletions(-) (limited to 'tests') diff --git a/tests/01_test_help.py b/tests/01_test_help.py index 07051785..68a6940b 100644 --- a/tests/01_test_help.py +++ b/tests/01_test_help.py @@ -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""" diff --git a/tests/02_test_upstream_source_tar_unpack.py b/tests/02_test_upstream_source_tar_unpack.py index 97bf76bb..e6147abd 100644 --- a/tests/02_test_upstream_source_tar_unpack.py +++ b/tests/02_test_upstream_source_tar_unpack.py @@ -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 diff --git a/tests/05_test_detection.py b/tests/05_test_detection.py index 126a2992..c3f729ba 100644 --- a/tests/05_test_detection.py +++ b/tests/05_test_detection.py @@ -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) diff --git a/tests/06_test_upstream_source.py b/tests/06_test_upstream_source.py index c6df6f14..6b2a1a1e 100644 --- a/tests/06_test_upstream_source.py +++ b/tests/06_test_upstream_source.py @@ -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 diff --git a/tests/08_test_patch.py b/tests/08_test_patch.py index df1d43d4..dd1532e2 100644 --- a/tests/08_test_patch.py +++ b/tests/08_test_patch.py @@ -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 diff --git a/tests/11_test_dch_main.py b/tests/11_test_dch_main.py index dbfc25cd..9bdc5c5b 100644 --- a/tests/11_test_dch_main.py +++ b/tests/11_test_dch_main.py @@ -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) diff --git a/tests/12_test_deb.py b/tests/12_test_deb.py index d46f987c..2be30976 100644 --- a/tests/12_test_deb.py +++ b/tests/12_test_deb.py @@ -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 diff --git a/tests/13_test_gbp_pq.py b/tests/13_test_gbp_pq.py index 7e78b153..0b400c21 100644 --- a/tests/13_test_gbp_pq.py +++ b/tests/13_test_gbp_pq.py @@ -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 import gbp.scripts.common.pq as pq diff --git a/tests/16_test_supercommand.py b/tests/16_test_supercommand.py index f72bb562..296ef8ed 100644 --- a/tests/16_test_supercommand.py +++ b/tests/16_test_supercommand.py @@ -16,7 +16,11 @@ """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): diff --git a/tests/component/rpm/test_import_srpm.py b/tests/component/rpm/test_import_srpm.py index c9a1a429..f6ee0ed0 100644 --- a/tests/component/rpm/test_import_srpm.py +++ b/tests/component/rpm/test_import_srpm.py @@ -48,8 +48,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 @@ -61,9 +61,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 @@ -79,8 +79,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 @@ -90,8 +90,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 @@ -126,8 +126,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 @@ -195,11 +195,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_import_orig.py b/tests/test_import_orig.py index d596d1df..aa39e380 100644 --- a/tests/test_import_orig.py +++ b/tests/test_import_orig.py @@ -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 diff --git a/tests/test_rpm.py b/tests/test_rpm.py index 3a6e6ceb..4fb3b0ca 100644 --- a/tests/test_rpm.py +++ b/tests/test_rpm.py @@ -253,8 +253,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 80c3b230..e45f4454 100644 --- a/tests/testutils.py +++ b/tests/testutils.py @@ -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 -- cgit v1.2.3