test_uploads_with_nondefault_rebase: fix git screen scraping

Newer versions of git quote branch names in their output; at least git
2.16.3 does. This causes all test_uploads_with_nondefault_rebase tests to
fail like this:

testtools.matchers._impl.MismatchError:
 'Branch test_branch set up to track remote branch maint from origin.'
 not in
  u"Switched to a new branch 'test_branch'\n\
 Branch 'test_branch' set up to track remote branch 'maint' from 'origin'."

Add a testtools.matchers.MatchesRegex() to support both styles.

Change-Id: I9f1417c53de2f7d638e845f553df3bd426a4c750
This commit is contained in:
Marc Herbert 2018-12-05 14:56:37 -08:00
parent d41f5d7d0a
commit 6f31931b87
1 changed files with 5 additions and 3 deletions

View File

@ -18,6 +18,7 @@
import json
import os
import shutil
import testtools
from git_review import tests
from git_review.tests import utils
@ -286,9 +287,10 @@ class GitReviewTestCase(tests.BaseGitReviewTestCase):
br_out = self._run_git('checkout',
'-b', 'test_branch', 'origin/maint')
expected_track = 'Branch test_branch set up to track remote' + \
' branch maint from origin.'
self.assertIn(expected_track, br_out)
expected_track = ".*\nBranch '?test_branch'? set up to track remote" + \
" branch '?maint'? from '?origin'?."
track_matcher = testtools.matchers.MatchesRegex(expected_track)
self.assertThat(br_out, track_matcher)
branches = self._run_git('branch', '-a')
expected_branch = '* test_branch'
observed = branches.split('\n')