From 256deec0610da3600d4893f4220c83d2f438b9ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Petter=20=C3=98ren=20Hauge?= Date: Wed, 3 Apr 2019 15:21:07 +0200 Subject: [PATCH] Add missing sys import And fixed minor bug --- python/res/job_queue/workflow.py | 3 ++- python/tests/res/job_queue/test_workflow.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/python/res/job_queue/workflow.py b/python/res/job_queue/workflow.py index c0a6648d63..b69458b799 100644 --- a/python/res/job_queue/workflow.py +++ b/python/res/job_queue/workflow.py @@ -1,4 +1,5 @@ import time +import sys from res.config import ConfigError from cwrap import BaseCClass from res import ResPrototype @@ -66,7 +67,7 @@ def run(self, ert, verbose=False, context=None): if not success: msg = "** Warning: The workflow file {} is not valid - "\ "make sure the workflow jobs are defined accordingly\n" - sys.stderr.write(msg.format(workflow.src_file)) + sys.stderr.write(msg.format(self.src_file)) self.__running = False return False diff --git a/python/tests/res/job_queue/test_workflow.py b/python/tests/res/job_queue/test_workflow.py index 1d8b058842..36ea271e98 100644 --- a/python/tests/res/job_queue/test_workflow.py +++ b/python/tests/res/job_queue/test_workflow.py @@ -55,3 +55,17 @@ def test_workflow_run(self): with open("dump2", "r") as f: self.assertEqual(f.read(), "dump_text_2") + + + def test_failing_workflow_run(self): + with TestAreaContext("python/job_queue/workflow") as work_area: + WorkflowCommon.createExternalDumpJob() + + joblist = WorkflowJoblist() + self.assertTrue(joblist.addJobFromFile("DUMP", "dump_job")) + self.assertTrue("DUMP" in joblist) + + workflow = Workflow("undefined", joblist) + context = SubstitutionList() + + self.assertFalse(workflow.run(None, verbose=True, context=context))