1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-02 18:21:12 +03:00

Merge pull request #1233 from ryanpetrello/fix-1215

more gracefully account for undefined stdout
This commit is contained in:
Ryan Petrello 2018-04-04 08:45:22 -04:00 committed by GitHub
commit 0359c4ed98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -885,6 +885,7 @@ class BaseTask(LogErrorsTask):
output_replacements = []
extra_update_fields = {}
event_ct = 0
stdout_handle = None
try:
kwargs['isolated'] = isolated_host is not None
self.pre_run_hook(instance, **kwargs)

View File

@ -13,6 +13,7 @@ import fcntl
import mock
import pytest
import yaml
from django.conf import settings
@ -295,6 +296,15 @@ class TestJobExecution:
class TestGenericRun(TestJobExecution):
def test_generic_failure(self):
self.task.build_private_data_files = mock.Mock(side_effect=IOError())
with pytest.raises(Exception):
self.task.run(self.pk)
update_model_call = self.task.update_model.call_args[1]
assert 'IOError' in update_model_call['result_traceback']
assert update_model_call['status'] == 'error'
assert update_model_call['emitted_events'] == 0
def test_cancel_flag(self):
self.instance.cancel_flag = True
with pytest.raises(Exception):