X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=yardstick%2Ftests%2Funit%2Fbenchmark%2Fcore%2Ftest_task.py;h=e1414c2aef2e8c0687f02124ac1572540826189e;hb=60e326463ae06038facf79f14e29901e9596e0dc;hp=0424c77a31830f6a185f62eb80770e3173ac3a09;hpb=2d6ded8483c7e8edc29bd33a5e519207f1bb511e;p=yardstick.git diff --git a/yardstick/tests/unit/benchmark/core/test_task.py b/yardstick/tests/unit/benchmark/core/test_task.py index 0424c77a3..e1414c2ae 100644 --- a/yardstick/tests/unit/benchmark/core/test_task.py +++ b/yardstick/tests/unit/benchmark/core/test_task.py @@ -9,11 +9,13 @@ import copy import io +import logging import os import sys import mock import six +from six.moves import builtins import unittest import uuid @@ -28,7 +30,7 @@ from yardstick.common import utils class TaskTestCase(unittest.TestCase): - @mock.patch.object(task, 'Context') + @mock.patch.object(base, 'Context') def test_parse_nodes_with_context_same_context(self, mock_context): scenario_cfg = { "nodes": { @@ -69,7 +71,7 @@ class TaskTestCase(unittest.TestCase): dispatcher2]) self.assertIsNone(t._do_output(output_config, {})) - @mock.patch.object(task, 'Context') + @mock.patch.object(base, 'Context') def test_parse_networks_from_nodes(self, mock_context): nodes = { 'node1': { @@ -133,7 +135,7 @@ class TaskTestCase(unittest.TestCase): self.assertEqual(mock_context.get_network.call_count, expected_get_network_calls) self.assertDictEqual(networks, expected) - @mock.patch.object(task, 'Context') + @mock.patch.object(base, 'Context') @mock.patch.object(task, 'base_runner') def test_run(self, mock_base_runner, *args): scenario = { @@ -156,7 +158,7 @@ class TaskTestCase(unittest.TestCase): t._run([scenario], False, "yardstick.out") runner.run.assert_called_once() - @mock.patch.object(task, 'Context') + @mock.patch.object(base, 'Context') @mock.patch.object(task, 'base_runner') def test_run_ProxDuration(self, mock_base_runner, *args): scenario = { @@ -322,9 +324,9 @@ class TaskTestCase(unittest.TestCase): actual_result = t._parse_options(options) self.assertEqual(expected_result, actual_result) - @mock.patch('six.moves.builtins.open', side_effect=mock.mock_open()) + @mock.patch.object(builtins, 'open', side_effect=mock.mock_open()) @mock.patch.object(task, 'utils') - @mock.patch('logging.root') + @mock.patch.object(logging, 'root') def test_set_log(self, mock_logging_root, *args): task_obj = task.Task() task_obj.task_id = 'task_id' @@ -561,7 +563,8 @@ key2: mock_open.assert_has_calls([mock.call('args_file'), mock.call('task_file')]) - def test__render_task_error_arguments(self): + @mock.patch.object(builtins, 'print') + def test__render_task_error_arguments(self, *args): with self.assertRaises(exceptions.TaskRenderArgumentError): task.TaskParser('task_file')._render_task('value1="var3"', None)