Update subprocess.check_output function for Py3 compatible issue.
The subprocess.check_output return type is "bytes" in python 3, we have
to convert bytes as string with .decode() in advance.
Bug: 144319716
Test: acloud-dev create
Change-Id: I379f5d65e850c0e4d4cca943076b712c23979759
diff --git a/setup/gcp_setup_runner_test.py b/setup/gcp_setup_runner_test.py
index cd81ab4..fa12d1f 100644
--- a/setup/gcp_setup_runner_test.py
+++ b/setup/gcp_setup_runner_test.py
@@ -95,7 +95,7 @@
self.assertEqual(cfg.project, "test_project")
@mock.patch("os.path.dirname", return_value="")
- @mock.patch("subprocess.check_output")
+ @mock.patch.object(utils, "CheckOutput")
def testSeupProjectZone(self, mock_runner, mock_path):
"""Test setup project and zone."""
gcloud_runner = gcp_setup_runner.GoogleSDKBins(mock_path)
@@ -227,7 +227,7 @@
self.gcp_env_runner.client_secret = "test_client_secret"
self.assertFalse(self.gcp_env_runner._NeedClientIDSetup(False))
- @mock.patch("subprocess.check_output")
+ @mock.patch.object(utils, "CheckOutput")
def testEnableGcloudServices(self, mock_run):
"""test enable Gcloud services."""
mock_run.return_value = ""
@@ -240,7 +240,7 @@
gcp_setup_runner._COMPUTE_ENGINE_SERVICE],
env=self.gcloud_runner._env, stderr=-2)])
- @mock.patch("subprocess.check_output")
+ @mock.patch.object(utils, "CheckOutput")
def testGoogleAPIService(self, mock_run):
"""Test GoogleAPIService"""
api_service = gcp_setup_runner.GoogleAPIService("service_name",
@@ -250,7 +250,7 @@
mock.call(["gcloud", "services", "enable", "service_name"],
env=self.gcloud_runner._env, stderr=-2)])
- @mock.patch("subprocess.check_output")
+ @mock.patch.object(utils, "CheckOutput")
def testCheckBillingEnable(self, mock_run):
"""Test CheckBillingEnable"""
# Test billing account in gcp project already enabled.