예제 #1
0
 def test_closure_is_picklable(self):
     # can pickle because we use cloudpickle
     def non_top_function(): return 4
     t1 = Task('t1', [non_top_function])
     t1p = runner.JobTask(t1).task_pickle
     t2 = pickle.loads(t1p)
     assert 4 == t2.actions[0].py_callable()
예제 #2
0
 def test_full_task(self, reporter, dep_manager):
     # test execute_task_subprocess can receive a full Task object
     run = runner.MRunner(dep_manager, reporter)
     t1 = Task('t1', [simple_result])
     task_q = Queue()
     task_q.put(runner.JobTask(t1)) # to test
     task_q.put(None) # to terminate function
     result_q = Queue()
     run.execute_task_subprocess(task_q, result_q, reporter.__class__)
     run.finish()
     # check result
     assert result_q.get() == {'name': 't1', 'reporter': 'execute_task'}
     assert result_q.get()['task']['result'] == 'my-result'
     assert result_q.empty()
예제 #3
0
 def test_full_task_fail(self, reporter, dep_manager):
     # test execute_task_subprocess can receive a full Task object
     run = runner.MRunner(dep_manager, reporter)
     t1 = Task('t1', [simple_fail])
     task_q = Queue()
     task_q.put(runner.JobTask(t1))  # to test
     task_q.put(None)  # to terminate function
     result_q = Queue()
     run.execute_task_subprocess(task_q, result_q, reporter.__class__)
     run.finish()
     # check result
     assert result_q.get() == {'name': 't1', 'reporter': 'execute_task'}
     res = result_q.get()
     assert res['name'] == 't1'
     assert isinstance(res['failure'], CatchedException)
     assert res['out'] == ['simple output\n']
     assert res['err'] == ['simple error\n']
     # assert result_q.get()['task']['result'] == 'my-result'
     assert result_q.empty()