Browse Source

Fix depot_tools tests when running without py2

Currently, running git cl presubmit fails without python 2 installed.
This CL replaces instances of 'python' in fetch_test.py with the generic
sys.executable and fixes a small error testRebaseUpdate due to an extra
period.

Bug: 1289839
Change-Id: Ib5802545af70fe0886448397fa76058bd2036527
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3407864
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
Gavin Mak 3 years ago
parent
commit
e9ea0d5c0d
2 changed files with 3 additions and 3 deletions
  1. 2 2
      tests/fetch_test.py
  2. 1 1
      tests/git_rebase_update_test.py

+ 2 - 2
tests/fetch_test.py

@@ -218,7 +218,7 @@ class TestCheckout(unittest.TestCase):
     exit_mock.assert_called_once()
     exit_mock.assert_called_once()
 
 
   def test_run_return_as_value(self):
   def test_run_return_as_value(self):
-    cmd = ['python', '-c', 'print("foo")']
+    cmd = [sys.executable, '-c', 'print("foo")']
 
 
     response = self.checkout.run(cmd, return_stdout=True)
     response = self.checkout.run(cmd, return_stdout=True)
     # we expect no response other than information about command
     # we expect no response other than information about command
@@ -227,7 +227,7 @@ class TestCheckout(unittest.TestCase):
     self.assertEqual('foo', response.strip())
     self.assertEqual('foo', response.strip())
 
 
   def test_run_print_to_stdout(self):
   def test_run_print_to_stdout(self):
-    cmd = ['python', '-c', 'print("foo")']
+    cmd = [sys.executable, '-c', 'print("foo")']
 
 
     # mocked version of sys.std* is not passed to subprocess, use temp files
     # mocked version of sys.std* is not passed to subprocess, use temp files
     with self._temporary_file() as stdout:
     with self._temporary_file() as stdout:

+ 1 - 1
tests/git_rebase_update_test.py

@@ -219,7 +219,7 @@ class GitRebaseUpdateTest(git_test_utils.GitRepoReadWriteTestBase):
 
 
     self.repo.git('checkout', 'origin/main')
     self.repo.git('checkout', 'origin/main')
     _, err = self.repo.capture_stdio(self.mv.main, ['special_K', 'cool branch'])
     _, err = self.repo.capture_stdio(self.mv.main, ['special_K', 'cool branch'])
-    self.assertIn('fatal: \'cool branch\' is not a valid branch name.', err)
+    self.assertIn('fatal: \'cool branch\' is not a valid branch name', err)
 
 
     self.repo.run(self.mv.main, ['special_K', 'cool_branch'])
     self.repo.run(self.mv.main, ['special_K', 'cool_branch'])
     branches = self.repo.run(set, self.gc.branches())
     branches = self.repo.run(set, self.gc.branches())