diff --git a/fixtures_git/github.py b/fixtures_git/github.py index f1ddef3..8948bec 100644 --- a/fixtures_git/github.py +++ b/fixtures_git/github.py @@ -65,13 +65,15 @@ class GithubRepoFixture(GithubLoginMixin, fixtures.Fixture): def _setUp(self): - # handle template_name missing 'XXXXX' result in it containing - # a single element so set suffix to '' in that case. - template_parts = iter(self.name_template.split('XXXXXX')) - prefix = next(template_parts) - suffix = next(template_parts, '') + # allow user to provide an exact name to use + if self.repo_name is None: + # handle template_name missing 'XXXXX' result in it containing + # a single element so set suffix to '' in that case. + template_parts = iter(self.name_template.split('XXXXXX')) + prefix = next(template_parts) + suffix = next(template_parts, '') - self.repo_name = ''.join([prefix, str(uuid.uuid4())[:8], suffix]) + self.repo_name = ''.join([prefix, str(uuid.uuid4())[:8], suffix]) self.addCleanup(self._delete_repo) diff --git a/tests/unit/test_github.py b/tests/unit/test_github.py index b2f61e4..97f5004 100644 --- a/tests/unit/test_github.py +++ b/tests/unit/test_github.py @@ -75,3 +75,16 @@ class TestGithubRepoFixture(testtools.TestCase): gh_repo.repo_name.split('-')[-1], testtools.matchers.MatchesRegex('[a-f0-9]{8}') ) + + @mock.patch('fixtures_git.github.GithubRepoFixture.login', + mock.Mock(return_value=mock.Mock())) + def test_tempname_exact_string(self): + + name = 'my-custom-tmp' + gh_repo = gh_fixture.GithubRepoFixture('owner', 'token') + gh_repo.repo_name = name + gh_repo.setUp() + self.assertThat( + gh_repo.repo_name, + testtools.matchers.Equals(name) + )