From 8d83b91049f4b2f3da6b77d39105a2213a8ce690 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=A9dric=20Ollivier?= Date: Mon, 12 Feb 2018 10:40:07 +0100 Subject: [PATCH] Export env vars via os.environ in test_cli_env.py MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit CONST shouldn't be used for getting/setting env vars. It adds complexity and may raise side effects. Change-Id: Id80a03aff6eb908a792f1d07addaad4770e8d0cb Signed-off-by: Cédric Ollivier --- functest/tests/unit/cli/commands/test_cli_env.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/functest/tests/unit/cli/commands/test_cli_env.py b/functest/tests/unit/cli/commands/test_cli_env.py index e5c409bf4..883772348 100644 --- a/functest/tests/unit/cli/commands/test_cli_env.py +++ b/functest/tests/unit/cli/commands/test_cli_env.py @@ -8,13 +8,13 @@ # pylint: disable=missing-docstring import logging +import os import re import unittest import mock from functest.cli.commands import cli_env -from functest.utils.constants import CONST class RegexMatch(object): # pylint: disable=too-few-public-methods @@ -34,22 +34,22 @@ class CliEnvTesting(unittest.TestCase): def _test_show_missing_env_var(self, var, *args): # pylint: disable=unused-argument if var == 'INSTALLER_TYPE': - CONST.__setattr__('INSTALLER_TYPE', None) + os.environ['INSTALLER_TYPE'] = '' reg_string = r"| INSTALLER: Unknown, \S+\s*|" elif var == 'INSTALLER_IP': - CONST.__setattr__('INSTALLER_IP', None) + os.environ['INSTALLER_IP'] = '' reg_string = r"| INSTALLER: \S+, Unknown\s*|" elif var == 'SCENARIO': - CONST.__setattr__('DEPLOY_SCENARIO', None) + os.environ['DEPLOY_SCENARIO'] = '' reg_string = r"| SCENARIO: Unknown\s*|" elif var == 'NODE': - CONST.__setattr__('NODE_NAME', None) + os.environ['NODE_NAME'] = '' reg_string = r"| POD: Unknown\s*|" elif var == 'BUILD_TAG': - CONST.__setattr__('BUILD_TAG', None) + os.environ['BUILD_TAG'] = '' reg_string = r"| BUILD TAG: None|" elif var == 'DEBUG': - CONST.__setattr__('CI_DEBUG', None) + os.environ['CI_DEBUG'] = '' reg_string = r"| DEBUG FLAG: false\s*|" with mock.patch('functest.cli.commands.cli_env.click.echo') \ -- 2.16.6