Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion openhtf/core/phase_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,10 @@ def _execute_phase_once(
try:
run_phase = phase_desc.options.run_if()
except Exception: # pylint: disable=broad-except
self.logger.debug('Phase %s stopped due to a fault in run_if function.',
phase_desc.name)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please line up the start of this line with the opening parenthesis on the previous line. Make sure you're using spaces and not tabs to do the alignment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

# Allow graceful termination
return PhaseExecutionOutcome(phase_descriptor.PhaseResult.STOP), None
return PhaseExecutionOutcome(ExceptionInfo(*sys.exc_info())), None

if not run_phase:
self.logger.debug('Phase %s skipped due to run_if returning falsey.',
Expand Down
17 changes: 9 additions & 8 deletions test/core/phase_executor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@
from openhtf.core import phase_descriptor
from openhtf.core import test_record

def run_if_with_exception():
raise Exception("run_if_with_exception")

_tr = None
def final(tr):
global _tr
_tr = tr

class PhaseExecutorTest(unittest.TestCase):

Expand Down Expand Up @@ -65,11 +58,19 @@ def test_execute_phase_with_repeat_limit_max_exceeds_default_limit(self):

def test_execute_phase_when_run_if_throws_exception(self):

def run_if_with_exception():
raise Exception("run_if_with_exception")

@openhtf.PhaseOptions(run_if=run_if_with_exception)
def phase():
pass

_tr = None
def final(tr):
nonlocal _tr
_tr = tr

test = openhtf.Test(phase)
test.add_output_callbacks(final)
test.execute()
self.assertEqual(_tr.outcome, test_record.Outcome.PASS)
self.assertEqual(_tr.outcome, test_record.Outcome.ERROR)