From 41a81e7f5ca5d3733e6e5655f5ece7859ce9f49b Mon Sep 17 00:00:00 2001 From: Cédric Ollivier Date: Mon, 11 Dec 2017 06:47:33 +0100 Subject: Add Python3 support in functest/ci MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: If13bfaa196b8dfab1e83feb28c5a4719c7acd8c7 Signed-off-by: Cédric Ollivier --- functest/ci/check_deployment.py | 4 ++-- functest/ci/run_tests.py | 3 ++- functest/tests/unit/ci/test_check_deployment.py | 4 ++-- functest/tests/unit/ci/test_tier_builder.py | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) (limited to 'functest') diff --git a/functest/ci/check_deployment.py b/functest/ci/check_deployment.py index ae016a800..8cc522f69 100644 --- a/functest/ci/check_deployment.py +++ b/functest/ci/check_deployment.py @@ -19,16 +19,16 @@ import logging import logging.config import os import pkg_resources +from six.moves.urllib.parse import urlparse import socket -from urlparse import urlparse from functest.opnfv_tests.openstack.snaps import snaps_utils +from snaps.openstack.tests import openstack_tests from snaps.openstack.utils import glance_utils from snaps.openstack.utils import keystone_utils from snaps.openstack.utils import neutron_utils from snaps.openstack.utils import nova_utils -from snaps.openstack.tests import openstack_tests __author__ = "Jose Lausuch " diff --git a/functest/ci/run_tests.py b/functest/ci/run_tests.py index d476bded8..67a6f1429 100644 --- a/functest/ci/run_tests.py +++ b/functest/ci/run_tests.py @@ -19,6 +19,7 @@ import sys import textwrap import prettytable +import six import yaml import functest.ci.tier_builder as tb @@ -118,7 +119,7 @@ class Runner(object): raise Exception("RC file %s does not exist..." % rc_file) logger.debug("Sourcing the OpenStack RC file...") os_utils.source_credentials(rc_file) - for key, value in os.environ.iteritems(): + for key, value in six.iteritems(os.environ): if re.search("OS_", key): if key == 'OS_AUTH_URL': CONST.__setattr__('OS_AUTH_URL', value) diff --git a/functest/tests/unit/ci/test_check_deployment.py b/functest/tests/unit/ci/test_check_deployment.py index 24e3ce53c..66d1b7afd 100644 --- a/functest/tests/unit/ci/test_check_deployment.py +++ b/functest/tests/unit/ci/test_check_deployment.py @@ -41,7 +41,7 @@ class CheckDeploymentTesting(unittest.TestCase): def test_check_rc(self): with mock.patch('functest.ci.check_deployment.os.path.isfile', returns=True) as m, \ - mock.patch('__builtin__.open', + mock.patch('six.moves.builtins.open', mock.mock_open(read_data='OS_AUTH_URL')): self.deployment.check_rc() self.assertTrue(m.called) @@ -55,7 +55,7 @@ class CheckDeploymentTesting(unittest.TestCase): self.assertTrue(msg in context) def test_check_rc_missing_os_auth(self): - with mock.patch('__builtin__.open', + with mock.patch('six.moves.builtins.open', mock.mock_open(read_data='test')), \ self.assertRaises(Exception) as context: msg = 'OS_AUTH_URL not defined in {}.'.format(self.rc_file) diff --git a/functest/tests/unit/ci/test_tier_builder.py b/functest/tests/unit/ci/test_tier_builder.py index 700c6e917..1dec9aed6 100644 --- a/functest/tests/unit/ci/test_tier_builder.py +++ b/functest/tests/unit/ci/test_tier_builder.py @@ -39,7 +39,7 @@ class TierBuilderTesting(unittest.TestCase): with mock.patch('functest.ci.tier_builder.yaml.safe_load', return_value=self.mock_yaml), \ - mock.patch('__builtin__.open', mock.mock_open()): + mock.patch('six.moves.builtins.open', mock.mock_open()): self.tierbuilder = tier_builder.TierBuilder('test_installer', 'test_scenario', 'testcases_file') -- cgit 1.2.3-korg