diff options
Diffstat (limited to 'tests/component/rpm/test_pq_rpm.py')
-rw-r--r-- | tests/component/rpm/test_pq_rpm.py | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/tests/component/rpm/test_pq_rpm.py b/tests/component/rpm/test_pq_rpm.py index 3746fb91..e1d97b7f 100644 --- a/tests/component/rpm/test_pq_rpm.py +++ b/tests/component/rpm/test_pq_rpm.py @@ -18,13 +18,14 @@ import os import tempfile -from nose.tools import assert_raises, eq_, ok_ # pylint: disable=E0611 +from nose.tools import assert_raises, eq_, ok_ # pylint: disable=E0611 from gbp.scripts.pq_rpm import main as pq from gbp.git import GitRepository from gbp.command_wrappers import GitCommand from tests.component.rpm import RpmRepoTestBase +from tests.testutils import capture_stderr # Disable "Method could be a function warning" # pylint: disable=R0201 @@ -35,6 +36,7 @@ def mock_pq(args): # Call pq-rpm with added arg0 return pq(['arg0'] + args) + class TestPqRpm(RpmRepoTestBase): """Basic tests for gbp-pq-rpm""" @@ -53,23 +55,14 @@ class TestPqRpm(RpmRepoTestBase): # Test invalid cmdline options with assert_raises(SystemExit): - mock_pq(['--invalid-arg=123']) + with capture_stderr() as c: + mock_pq(['--invalid-arg=123']) def test_import_outside_repo(self): """Run pq-rpm when not in a git repository""" eq_(mock_pq(['export']), 1) self._check_log(0, 'gbp:error: %s is not a git repository' % - os.path.abspath(os.getcwd())) - - def test_invalid_config_file(self): - """Test invalid config file""" - # Create dummy invalid config file and run pq-rpm - GitRepository.create('.') - with open('.gbp.conf', 'w') as conffd: - conffd.write('foobar\n') - eq_(mock_pq(['foo']), 1) - self._check_log(0, 'gbp:error: Invalid config file: File contains no ' - 'section headers.') + os.path.abspath(os.getcwd())) def test_import_export(self): """Basic test for patch import and export""" @@ -327,7 +320,7 @@ class TestPqRpm(RpmRepoTestBase): eq_(mock_pq(['export']), 0) files = ['.gbp.conf', '.gitignore', 'bar.tar.gz', 'foo.txt', 'gbp-test.spec', 'my.patch', - '%s-to-%s.diff' % (upstr_rev, merge_rev), '0002-my2.patch'] + '%s-to-%s.diff' % (upstr_rev, merge_rev), '0002-my2.patch'] self._check_repo_state(repo, 'master', branches, files) def test_import_unapplicable_patch(self): @@ -339,10 +332,10 @@ class TestPqRpm(RpmRepoTestBase): patch_file.write('-this-does\n+not-apply\n') eq_(mock_pq(['import']), 1) self._check_log(-2, "(" - "Aborting|" - "Please, commit your changes or stash them|" - "gbp:error: Import failed.* You have local changes" - ")") + "Aborting|" + "Please, commit your changes or stash them|" + "gbp:error: Import failed.* You have local changes" + ")") self._check_repo_state(repo, 'master', branches) # Now commit the changes to the patch and try again @@ -351,4 +344,3 @@ class TestPqRpm(RpmRepoTestBase): eq_(mock_pq(['import']), 1) self._check_log(-2, "gbp:error: Import failed: Error running git apply") self._check_repo_state(repo, 'master', branches) - |