summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCedric Ollivier <cedric.ollivier@orange.com>2017-12-12 14:01:54 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-12-12 14:01:54 +0000
commitdef49808fcca40d837f0a37cc23783af80198c01 (patch)
treec30493618e1cec29cbcd68e9a0ea1de7f10d2577
parent250a7936cc34e2e22c7a9a8f766c9ee0bdcb9f4c (diff)
parent7a07dd0968ab9775e7bbfd59ff19bddcb8605af4 (diff)
Merge "Add python3 support in cli"
-rw-r--r--functest/cli/commands/cli_env.py4
-rw-r--r--functest/cli/commands/cli_os.py13
-rw-r--r--functest/tests/unit/cli/commands/test_cli_os.py5
-rw-r--r--tox.ini1
4 files changed, 15 insertions, 8 deletions
diff --git a/functest/cli/commands/cli_env.py b/functest/cli/commands/cli_env.py
index 0e0afe529..c41f8f340 100644
--- a/functest/cli/commands/cli_env.py
+++ b/functest/cli/commands/cli_env.py
@@ -12,6 +12,8 @@ import prettytable
from functest.utils.constants import CONST
+import six
+
class Env(object):
@@ -52,7 +54,7 @@ class CliEnv(Env):
msg = prettytable.PrettyTable(
header_style='upper', padding_width=5,
field_names=['Functest Environment', 'value'])
- for key, value in env_info.iteritems():
+ for key, value in six.iteritems(env_info):
if key is not None:
msg.add_row([key, value])
click.echo(msg.get_string())
diff --git a/functest/cli/commands/cli_os.py b/functest/cli/commands/cli_os.py
index 71cd78c58..1ec705a5d 100644
--- a/functest/cli/commands/cli_os.py
+++ b/functest/cli/commands/cli_os.py
@@ -9,9 +9,10 @@
import os
-from urlparse import urlparse
import click
+import six
+from six.moves.urllib.parse import urlparse
from functest.ci import check_deployment
from functest.utils.constants import CONST
@@ -58,16 +59,18 @@ class OpenStack(object):
def snapshot_create(self):
self.ping_endpoint()
if os.path.isfile(self.snapshot_file):
- answer = raw_input("It seems there is already an OpenStack "
- "snapshot. Do you want to overwrite it with "
- "the current OpenStack status? [y|n]\n")
+ answer = six.moves.input(
+ "It seems there is already an OpenStack "
+ "snapshot. Do you want to overwrite it with "
+ "the current OpenStack status? [y|n]\n")
while True:
if answer.lower() in ["y", "yes"]:
break
elif answer.lower() in ["n", "no"]:
return
else:
- answer = raw_input("Invalid answer. Please type [y|n]\n")
+ answer = six.moves.input(
+ "Invalid answer. Please type [y|n]\n")
click.echo("Generating Openstack snapshot...")
os_snapshot.main()
diff --git a/functest/tests/unit/cli/commands/test_cli_os.py b/functest/tests/unit/cli/commands/test_cli_os.py
index 806bc9312..434370a5c 100644
--- a/functest/tests/unit/cli/commands/test_cli_os.py
+++ b/functest/tests/unit/cli/commands/test_cli_os.py
@@ -82,7 +82,7 @@ class CliOpenStackTesting(unittest.TestCase):
return_value=True)
@mock.patch('functest.cli.commands.cli_os.click.echo')
def test_snapshot_create_overwrite(self, mock_click_echo, mock_os_path):
- with mock.patch('__builtin__.raw_input', return_value="y") \
+ with mock.patch('six.moves.input', return_value="y") \
as mock_raw_input, \
mock.patch.object(self.cli_os, 'ping_endpoint'), \
mock.patch('functest.cli.commands.cli_os.os_snapshot.main') \
@@ -111,7 +111,8 @@ class CliOpenStackTesting(unittest.TestCase):
return_value=True)
@mock.patch('functest.cli.commands.cli_os.click.echo')
def test_snapshot_show_default(self, mock_click_echo, mock_os_path):
- with mock.patch('__builtin__.open', mock.mock_open(read_data='0')) \
+ with mock.patch('six.moves.builtins.open',
+ mock.mock_open(read_data='0')) \
as m:
self.cli_os.snapshot_file = self.snapshot_file
self.cli_os.snapshot_show()
diff --git a/tox.ini b/tox.ini
index 9d5988a6c..62bed4f7b 100644
--- a/tox.ini
+++ b/tox.ini
@@ -57,6 +57,7 @@ commands =
[testenv:py35]
dirs =
functest/tests/unit/ci
+ functest/tests/unit/cli
functest/tests/unit/core
functest/tests/unit/energy
functest/tests/unit/odl