diff options
-rw-r--r-- | pbr/packaging.py | 2 | ||||
-rw-r--r-- | pbr/tests/base.py | 4 | ||||
-rw-r--r-- | pbr/tests/test_packaging.py | 35 | ||||
-rw-r--r-- | requirements.txt | 2 |
4 files changed, 33 insertions, 10 deletions
diff --git a/pbr/packaging.py b/pbr/packaging.py index 9b022a7..c4a5977 100644 --- a/pbr/packaging.py +++ b/pbr/packaging.py @@ -289,7 +289,7 @@ def write_git_changelog(git_dir=None, dest_dir=os.path.curdir, underline = len(tag) * '-' if not first_line: - changelog_file.write(u'\n') + changelog_file.write('\n') changelog_file.write( ("%(tag)s\n%(underline)s\n\n" % dict(tag=tag, diff --git a/pbr/tests/base.py b/pbr/tests/base.py index f18dadc..6c31bc9 100644 --- a/pbr/tests/base.py +++ b/pbr/tests/base.py @@ -92,6 +92,10 @@ class BaseTestCase(testtools.TestCase, testresources.ResourcedTestCase): self.log_fixture = self.useFixture( fixtures.FakeLogger('pbr')) + # Older git does not have config --local, so create a temporary home + # directory to permit using git config --global without stepping on + # developer configuration. + self.useFixture(fixtures.TempHomeDir()) self.useFixture(fixtures.NestedTempfile()) self.useFixture(fixtures.FakeLogger()) self.useFixture(fixtures.EnvironmentVariable('PBR_VERSION', '0.0')) diff --git a/pbr/tests/test_packaging.py b/pbr/tests/test_packaging.py index d382d37..abcc68d 100644 --- a/pbr/tests/test_packaging.py +++ b/pbr/tests/test_packaging.py @@ -48,16 +48,36 @@ from pbr import packaging from pbr.tests import base +class TestRepo(fixtures.Fixture): + """A git repo for testing with. + + Use of TempHomeDir with this fixture is strongly recommended as due to the + lack of config --local in older gits, it will write to the users global + configuration without TempHomeDir. + """ + + def __init__(self, basedir): + super(TestRepo, self).__init__() + self._basedir = basedir + + def setUp(self): + super(TestRepo, self).setUp() + base._run_cmd(['git', 'init', '.'], self._basedir) + base._run_cmd( + ['git', 'config', '--global', 'user.email', 'example@example.com'], + self._basedir) + base._run_cmd(['git', 'add', '.'], self._basedir) + + def commit(self): + base._run_cmd(['git', 'commit', '-m', 'test commit'], self._basedir) + + class TestPackagingInGitRepoWithCommit(base.BaseTestCase): def setUp(self): super(TestPackagingInGitRepoWithCommit, self).setUp() - self.useFixture(fixtures.TempHomeDir()) - self._run_cmd( - 'git', ['config', '--global', 'user.email', 'nobody@example.com']) - self._run_cmd('git', ['init', '.']) - self._run_cmd('git', ['add', '.']) - self._run_cmd('git', ['commit', '-m', 'test commit']) + repo = self.useFixture(TestRepo(self.package_dir)) + repo.commit() self.run_setup('sdist') return @@ -78,8 +98,7 @@ class TestPackagingInGitRepoWithoutCommit(base.BaseTestCase): def setUp(self): super(TestPackagingInGitRepoWithoutCommit, self).setUp() - self._run_cmd('git', ['init', '.']) - self._run_cmd('git', ['add', '.']) + self.useFixture(TestRepo(self.package_dir)) self.run_setup('sdist') return diff --git a/requirements.txt b/requirements.txt index 9dd4ec3..a1b589e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -pip>=1.4 +pip |