mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
tests: switch to 4 space indent
Reformat this dir by itself to help merging with conflicts with other CLs. Reformatted using: parallel ./yapf -i -- tests/*.py ~/chromiumos/chromite/contrib/reflow_overlong_comments tests/*.py These files still had lines (strings) that were too long, so the pylint warnings were suppressed with a TODO. tests/bot_update_coverage_test.py tests/cipd_bootstrap_test.py tests/gclient_eval_unittest.py tests/gclient_git_smoketest.py tests/gclient_scm_test.py tests/gclient_smoketest.py tests/gclient_test.py tests/gclient_transitions_smoketest.py tests/gclient_utils_test.py tests/git_cl_test.py tests/git_hyper_blame_test.py tests/git_rebase_update_test.py tests/lockfile_test.py tests/metrics_test.py tests/presubmit_canned_checks_test.py tests/presubmit_unittest.py tests/roll_dep_test.py Change-Id: I8fed04b4ba81d54b8f45da612213aad27a9e1a2c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4842592 Commit-Queue: Josip Sokcevic <sokcevic@chromium.org> Reviewed-by: Josip Sokcevic <sokcevic@chromium.org> Auto-Submit: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
@@ -18,39 +18,40 @@ import git_find_releases
|
||||
|
||||
|
||||
class TestGitFindReleases(unittest.TestCase):
|
||||
@mock.patch('sys.stdout', StringIO())
|
||||
@mock.patch('git_common.run', return_value='')
|
||||
def test_invalid_commit(self, git_run):
|
||||
result = git_find_releases.main(['foo'])
|
||||
self.assertEqual(1, result)
|
||||
self.assertEqual('foo not found', sys.stdout.getvalue().strip())
|
||||
git_run.assert_called_once_with('name-rev', '--tags', '--name-only', 'foo')
|
||||
@mock.patch('sys.stdout', StringIO())
|
||||
@mock.patch('git_common.run', return_value='')
|
||||
def test_invalid_commit(self, git_run):
|
||||
result = git_find_releases.main(['foo'])
|
||||
self.assertEqual(1, result)
|
||||
self.assertEqual('foo not found', sys.stdout.getvalue().strip())
|
||||
git_run.assert_called_once_with('name-rev', '--tags', '--name-only',
|
||||
'foo')
|
||||
|
||||
@mock.patch('sys.stdout', StringIO())
|
||||
@mock.patch('git_common.run')
|
||||
def test_no_merge(self, git_run):
|
||||
def git_run_function(*args):
|
||||
assert len(args) > 1
|
||||
if args[0] == 'name-rev' and args[1] == '--tags':
|
||||
return 'undefined'
|
||||
@mock.patch('sys.stdout', StringIO())
|
||||
@mock.patch('git_common.run')
|
||||
def test_no_merge(self, git_run):
|
||||
def git_run_function(*args):
|
||||
assert len(args) > 1
|
||||
if args[0] == 'name-rev' and args[1] == '--tags':
|
||||
return 'undefined'
|
||||
|
||||
if args[0] == 'name-rev' and args[1] == '--refs':
|
||||
return '1.0.0'
|
||||
if args[0] == 'name-rev' and args[1] == '--refs':
|
||||
return '1.0.0'
|
||||
|
||||
if args[0] == 'log':
|
||||
return ''
|
||||
assert False, "Unexpected arguments for git.run"
|
||||
if args[0] == 'log':
|
||||
return ''
|
||||
assert False, "Unexpected arguments for git.run"
|
||||
|
||||
git_run.side_effect = git_run_function
|
||||
result = git_find_releases.main(['foo'])
|
||||
self.assertEqual(0, result)
|
||||
stdout = sys.stdout.getvalue().strip()
|
||||
self.assertIn('commit foo was', stdout)
|
||||
self.assertIn('No merges found', stdout)
|
||||
self.assertEqual(3, git_run.call_count)
|
||||
git_run.side_effect = git_run_function
|
||||
result = git_find_releases.main(['foo'])
|
||||
self.assertEqual(0, result)
|
||||
stdout = sys.stdout.getvalue().strip()
|
||||
self.assertIn('commit foo was', stdout)
|
||||
self.assertIn('No merges found', stdout)
|
||||
self.assertEqual(3, git_run.call_count)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logging.basicConfig(
|
||||
level=logging.DEBUG if '-v' in sys.argv else logging.ERROR)
|
||||
unittest.main()
|
||||
logging.basicConfig(
|
||||
level=logging.DEBUG if '-v' in sys.argv else logging.ERROR)
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user