From 5ff1be8a74b1adf3ecf0597d0cb22d3fc7a499a1 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Mon, 12 Sep 2016 08:18:50 +0200 Subject: test_rpm_ch: use GIT_AUTHOR_* env vars Use env vars in the test instead of config file otherwise the tests fail if a user uses GIT_AUTHOR_* vars on the command line since these overwrite the config file values. --- tests/component/rpm/test_rpm_ch.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/component/rpm/test_rpm_ch.py b/tests/component/rpm/test_rpm_ch.py index 4bc46bd1..3124688a 100644 --- a/tests/component/rpm/test_rpm_ch.py +++ b/tests/component/rpm/test_rpm_ch.py @@ -190,11 +190,19 @@ class TestRpmCh(RpmRepoTestBase): eq_(mock_ch(['--git-author', '--since=HEAD^1']), 0) # Test the --git-author option + saved_author = os.environ.get('GIT_AUTHOR_NAME') + saved_email = os.environ.get('GIT_AUTHOR_EMAIL') + os.environ['GIT_AUTHOR_NAME'] = 'John Doe' + os.environ['GIT_AUTHOR_EMAIL'] = 'jd@host.com' with open(os.path.join(repo.git_dir, 'config'), 'a') as fobj: fobj.write('[user]\n name=John Doe\n email=jd@host.com\n') eq_(mock_ch(['--git-author', '--since=HEAD^']), 0) header = self.read_file('packaging/gbp-test-native.changes')[0] ok_(re.match(r'.+ John Doe .+', header), header) + if saved_author: + os.environ['GIT_AUTHOR_NAME'] = saved_author + if saved_email: + os.environ['GIT_AUTHOR_EMAIL'] = saved_email def test_option_full(self): """Test the --full cmdline option""" -- cgit v1.2.3