aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoss Brattain <ross.b.brattain@intel.com>2017-10-06 20:20:49 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-10-06 20:20:49 +0000
commit948df73fa78aee82526457df075a43ec590cd536 (patch)
tree778da8928eff9247a665e6eb19722f5ba7ac7a97
parentaf71c468fe83a5149e0e18cdb233e059302209e3 (diff)
parent2fadf7aec9e2761c39d29d8af1ee7d69d154652d (diff)
Merge "fix random test_task unittest fail due to os.environ mock"
-rw-r--r--tests/unit/benchmark/core/test_task.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/tests/unit/benchmark/core/test_task.py b/tests/unit/benchmark/core/test_task.py
index 737e7058b..bed0bb6d8 100644
--- a/tests/unit/benchmark/core/test_task.py
+++ b/tests/unit/benchmark/core/test_task.py
@@ -165,12 +165,12 @@ class TaskTestCase(unittest.TestCase):
result = t._check_precondition(cfg)
self.assertTrue(result)
- @mock.patch('yardstick.benchmark.core.task.os.environ')
- def test_parse_suite_no_constraint_no_args(self, mock_environ):
+ def test_parse_suite_no_constraint_no_args(self):
SAMPLE_SCENARIO_PATH = "no_constraint_no_args_scenario_sample.yaml"
t = task.TaskParser(self._get_file_abspath(SAMPLE_SCENARIO_PATH))
- mock_environ.get.side_effect = ['huawei-pod1', 'compass']
- task_files, task_args, task_args_fnames = t.parse_suite()
+ with mock.patch('yardstick.benchmark.core.task.os.environ',
+ new={'NODE_NAME': 'huawei-pod1', 'INSTALLER_TYPE': 'compass'}):
+ task_files, task_args, task_args_fnames = t.parse_suite()
print("files=%s, args=%s, fnames=%s" % (task_files, task_args,
task_args_fnames))
self.assertEqual(task_files[0], self.change_to_abspath(
@@ -186,8 +186,9 @@ class TaskTestCase(unittest.TestCase):
def test_parse_suite_no_constraint_with_args(self, mock_environ):
SAMPLE_SCENARIO_PATH = "no_constraint_with_args_scenario_sample.yaml"
t = task.TaskParser(self._get_file_abspath(SAMPLE_SCENARIO_PATH))
- mock_environ.get.side_effect = ['huawei-pod1', 'compass']
- task_files, task_args, task_args_fnames = t.parse_suite()
+ with mock.patch('yardstick.benchmark.core.task.os.environ',
+ new={'NODE_NAME': 'huawei-pod1', 'INSTALLER_TYPE': 'compass'}):
+ task_files, task_args, task_args_fnames = t.parse_suite()
print("files=%s, args=%s, fnames=%s" % (task_files, task_args,
task_args_fnames))
self.assertEqual(task_files[0], self.change_to_abspath(
@@ -204,8 +205,9 @@ class TaskTestCase(unittest.TestCase):
def test_parse_suite_with_constraint_no_args(self, mock_environ):
SAMPLE_SCENARIO_PATH = "with_constraint_no_args_scenario_sample.yaml"
t = task.TaskParser(self._get_file_abspath(SAMPLE_SCENARIO_PATH))
- mock_environ.get.side_effect = ['huawei-pod1', 'compass']
- task_files, task_args, task_args_fnames = t.parse_suite()
+ with mock.patch('yardstick.benchmark.core.task.os.environ',
+ new={'NODE_NAME': 'huawei-pod1', 'INSTALLER_TYPE': 'compass'}):
+ task_files, task_args, task_args_fnames = t.parse_suite()
print("files=%s, args=%s, fnames=%s" % (task_files, task_args,
task_args_fnames))
self.assertEqual(task_files[0], self.change_to_abspath(
@@ -221,8 +223,9 @@ class TaskTestCase(unittest.TestCase):
def test_parse_suite_with_constraint_with_args(self, mock_environ):
SAMPLE_SCENARIO_PATH = "with_constraint_with_args_scenario_sample.yaml"
t = task.TaskParser(self._get_file_abspath(SAMPLE_SCENARIO_PATH))
- mock_environ.get.side_effect = ['huawei-pod1', 'compass']
- task_files, task_args, task_args_fnames = t.parse_suite()
+ with mock.patch('yardstick.benchmark.core.task.os.environ',
+ new={'NODE_NAME': 'huawei-pod1', 'INSTALLER_TYPE': 'compass'}):
+ task_files, task_args, task_args_fnames = t.parse_suite()
print("files=%s, args=%s, fnames=%s" % (task_files, task_args,
task_args_fnames))
self.assertEqual(task_files[0], self.change_to_abspath(