utils: create TASK_LOG_DIR if it doesn't exist 13/39213/1
authorRoss Brattain <ross.b.brattain@intel.com>
Sun, 13 Aug 2017 20:36:57 +0000 (13:36 -0700)
committerRoss Brattain <ross.b.brattain@intel.com>
Mon, 14 Aug 2017 00:38:33 +0000 (17:38 -0700)
Change-Id: I10630599065e6c159b137bd4d6ee89353a1c411b
Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
tests/unit/benchmark/core/test_task.py
yardstick/benchmark/core/task.py

index 25688bf..14027e4 100644 (file)
@@ -290,8 +290,9 @@ class TaskTestCase(unittest.TestCase):
         task.change_server_name(scenario, suffix)
         self.assertTrue(scenario['target']['name'], 'demo-8')
 
+    @mock.patch('yardstick.benchmark.core.task.utils')
     @mock.patch('yardstick.benchmark.core.task.logging')
-    def test_set_log(self, mock_logging):
+    def test_set_log(self, mock_logging, mock_utils):
         task_obj = task.Task()
         task_obj.task_id = 'task_id'
         task_obj._set_log()
index dd35bd4..9605e94 100644 (file)
@@ -162,6 +162,7 @@ class Task(object):     # pragma: no cover
         log_format = '%(asctime)s %(name)s %(filename)s:%(lineno)d %(levelname)s %(message)s'
         log_formatter = logging.Formatter(log_format)
 
+        utils.makedirs(constants.TASK_LOG_DIR)
         log_path = os.path.join(constants.TASK_LOG_DIR, '{}.log'.format(self.task_id))
         log_handler = logging.FileHandler(log_path)
         log_handler.setFormatter(log_formatter)