From e7eee58cd132f4f68cdf3e319bae6b0283fd2678 Mon Sep 17 00:00:00 2001 From: Cédric Ollivier Date: Mon, 12 Feb 2018 11:22:06 +0100 Subject: Export env vars via os.environ in test_openstack_utils.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CONST shouldn't be used for getting/setting env vars. It adds complexity and may raise side effects. Change-Id: I8319748dd2f0abb95b82a2f65191cac8ccba7f5e Signed-off-by: Cédric Ollivier --- functest/tests/unit/utils/test_openstack_utils.py | 4 ++-- functest/utils/openstack_utils.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/functest/tests/unit/utils/test_openstack_utils.py b/functest/tests/unit/utils/test_openstack_utils.py index 0a7177fc..259e60d5 100644 --- a/functest/tests/unit/utils/test_openstack_utils.py +++ b/functest/tests/unit/utils/test_openstack_utils.py @@ -9,12 +9,12 @@ import copy import logging +import os import unittest import mock from functest.utils import openstack_utils -from functest.utils.constants import CONST class OSUtilsTesting(unittest.TestCase): @@ -1577,7 +1577,7 @@ class OSUtilsTesting(unittest.TestCase): def test_create_tenant_default(self): with mock.patch('functest.utils.openstack_utils.' 'is_keystone_v3', return_value=True): - CONST.__setattr__('OS_PROJECT_DOMAIN_NAME', 'Default') + os.environ['OS_PROJECT_DOMAIN_NAME'] = 'Default' self.assertEqual(openstack_utils. create_tenant(self.keystone_client, 'test_tenant', diff --git a/functest/utils/openstack_utils.py b/functest/utils/openstack_utils.py index f7069a63..b779997c 100644 --- a/functest/utils/openstack_utils.py +++ b/functest/utils/openstack_utils.py @@ -1320,7 +1320,7 @@ def get_domain_id(keystone_client, domain_name): def create_tenant(keystone_client, tenant_name, tenant_description): try: if is_keystone_v3(): - domain_name = CONST.__getattribute__('OS_PROJECT_DOMAIN_NAME') + domain_name = os.environ['OS_PROJECT_DOMAIN_NAME'] domain_id = get_domain_id(keystone_client, domain_name) tenant = keystone_client.projects.create( name=tenant_name, -- cgit 1.2.3-korg