acloud: fix py3 compatible issue: NameError: of name 'raw_input' is not defined
1 replace raw_input as six.moves.input.
2 replace __builtins__.raw_input as six.moves.input
3 replace __builtins__.open as six.moves.builtins.open.
BUG: 137195528
BUG: 144319256
Test: atest acloud_test --host &&
acloud-dev create &
acloud-dev setup &
acloud-dev reconnect &
acloud-dev setup
Change-Id: I1dd4e97a8c35e66639e7be8f5152f4713cd8fd35
diff --git a/internal/lib/utils_test.py b/internal/lib/utils_test.py
index 4b3cfe8..480b4d2 100644
--- a/internal/lib/utils_test.py
+++ b/internal/lib/utils_test.py
@@ -26,6 +26,7 @@
import unittest
import mock
+import six
from acloud import errors
from acloud.internal.lib import driver_test_lib
@@ -181,7 +182,7 @@
mock_open = mock.mock_open(read_data=public_key)
self.Patch(subprocess, "check_output")
self.Patch(os, "rename")
- with mock.patch("__builtin__.open", mock_open):
+ with mock.patch.object(six.moves.builtins, "open", mock_open):
utils.CreateSshKeyPairIfNotExist(private_key, public_key)
self.assertEqual(subprocess.check_output.call_count, 1) #pylint: disable=no-member
subprocess.check_output.assert_called_with( #pylint: disable=no-member
@@ -252,7 +253,7 @@
mock.call(16)
])
- @mock.patch("__builtin__.raw_input")
+ @mock.patch.object(six.moves, "input")
def testGetAnswerFromList(self, mock_raw_input):
"""Test GetAnswerFromList."""
answer_list = ["image1.zip", "image2.zip", "image3.zip"]