def test_internal_error(self): test_case = _single_successful_instruction_in_each_phase() self._check( Arrangement(test_case, atc_execute=execute_action_that_raises( test.ImplementationErrorTestException())), Expectation( asrt_result.matches2( ExecutionFailureStatus.INTERNAL_ERROR, asrt_result.has_sds(), asrt_result.has_no_action_to_check_outcome(), ExpectedFailureForPhaseFailure.new_with_exception( phase_step.ACT__EXECUTE, test.ImplementationErrorTestException)), [phase_step.ACT__PARSE] + SYMBOL_VALIDATION_STEPS__ONCE + PRE_SDS_VALIDATION_STEPS__ONCE + [ phase_step.SETUP__MAIN, phase_step.SETUP__VALIDATE_POST_SETUP, phase_step.ACT__VALIDATE_POST_SETUP, phase_step.BEFORE_ASSERT__VALIDATE_POST_SETUP, phase_step.ASSERT__VALIDATE_POST_SETUP, phase_step.ACT__VALIDATE_EXE_INPUT, phase_step.ACT__PREPARE, phase_step.ACT__EXECUTE, (phase_step.CLEANUP__MAIN, PreviousPhase.ACT), ], ))
def test_internal_error(self): test_case = TestCaseGeneratorWithExtraInstrsBetweenRecordingInstr() \ .add(PartialPhase.SETUP, test.setup_phase_instruction_that( main=do_raise(test.ImplementationErrorTestException()))) self._check( Arrangement(test_case, atc_execute=execute_action_that_returns_exit_code(5)), Expectation( asrt_result.matches2( ExecutionFailureStatus.INTERNAL_ERROR, asrt_result.has_sds(), asrt_result.has_no_action_to_check_outcome(), ExpectedFailureForInstructionFailure.new_with_exception( phase_step.SETUP__MAIN, test_case.the_extra(PartialPhase.SETUP)[0].source, test.ImplementationErrorTestException), ), [phase_step.ACT__PARSE] + SYMBOL_VALIDATION_STEPS__TWICE + PRE_SDS_VALIDATION_STEPS__TWICE + [ phase_step.SETUP__MAIN, (phase_step.CLEANUP__MAIN, PreviousPhase.SETUP), (phase_step.CLEANUP__MAIN, PreviousPhase.SETUP), ], ))
def test_internal_error_in_act_execute(self): test_case = _single_successful_instruction_in_each_phase( single_line_sequence(72, 'ignored')) self._check( Arrangement( test_case, ActorThatRunsConstantActions( execute_action=execute_action_that_raises( test.ImplementationErrorTestException()))), Expectation( asrt_result.matches2( ExecutionFailureStatus.INTERNAL_ERROR, asrt_result.has_sds(), asrt_result.has_no_action_to_check_outcome(), ExpectedFailureForPhaseFailure.new_with_exception( phase_step.ACT__EXECUTE, test.ImplementationErrorTestException)), atc_stdout_output=asrt.equals(''), atc_stderr_output=asrt.equals(''), step_recordings=[phase_step.ACT__PARSE] + SYMBOL_VALIDATION_STEPS__ONCE + PRE_SDS_VALIDATION_STEPS__ONCE + [ phase_step.SETUP__MAIN, phase_step.SETUP__VALIDATE_POST_SETUP, phase_step.ACT__VALIDATE_POST_SETUP, phase_step.BEFORE_ASSERT__VALIDATE_POST_SETUP, phase_step.ASSERT__VALIDATE_POST_SETUP, phase_step.ACT__VALIDATE_EXE_INPUT, phase_step.ACT__PREPARE, phase_step.ACT__EXECUTE, (phase_step.CLEANUP__MAIN, PreviousPhase.ACT), ], ))
def test_with_internal_error(self): test_case = test_case_with_two_instructions_in_each_phase() \ .add(phase_identifier.CONFIGURATION, test.ConfigurationPhaseInstructionThatSetsExecutionMode(TestCaseStatus.FAIL)) \ .add(phase_identifier.CLEANUP, test.cleanup_phase_instruction_that( main=do_raise(test.ImplementationErrorTestException()))) self._check( Arrangement( test_case, execute_test_action=execute_action_that_returns_exit_code( 128)), Expectation( asrt_result.matches2( FullExeResultStatus.INTERNAL_ERROR, asrt_result.has_sds(), asrt_result.has_action_to_check_outcome_with_exit_code( 128), ExpectedFailureForInstructionFailure.new_with_exception( phase_step.CLEANUP__MAIN, test_case.the_extra( phase_identifier.CLEANUP)[0].source, test.ImplementationErrorTestException), ), [ phase_step.CONFIGURATION__MAIN, phase_step.CONFIGURATION__MAIN ] + [phase_step.ACT__PARSE] + SYMBOL_VALIDATION_STEPS__TWICE + PRE_SDS_VALIDATION_STEPS__TWICE + [ phase_step.SETUP__MAIN, phase_step.SETUP__MAIN, phase_step.SETUP__VALIDATE_POST_SETUP, phase_step.SETUP__VALIDATE_POST_SETUP, phase_step.ACT__VALIDATE_POST_SETUP, phase_step.BEFORE_ASSERT__VALIDATE_POST_SETUP, phase_step.BEFORE_ASSERT__VALIDATE_POST_SETUP, phase_step.ASSERT__VALIDATE_POST_SETUP, phase_step.ASSERT__VALIDATE_POST_SETUP, phase_step.ACT__PREPARE, phase_step.ACT__EXECUTE, phase_step.BEFORE_ASSERT__MAIN, phase_step.BEFORE_ASSERT__MAIN, phase_step.ASSERT__MAIN, phase_step.ASSERT__MAIN, (phase_step.CLEANUP__MAIN, PreviousPhase.ASSERT), ], ))
def test_exception(self): test_case = _single_successful_instruction_in_each_phase() self._check( Arrangement(test_case, atc_validate_pre_sds=validate_action_that_raises( test.ImplementationErrorTestException())), Expectation( asrt_result.matches2( ExecutionFailureStatus.INTERNAL_ERROR, asrt_result.has_no_sds(), asrt_result.has_no_action_to_check_outcome(), ExpectedFailureForPhaseFailure.new_with_exception( phase_step.ACT__VALIDATE_PRE_SDS, test.ImplementationErrorTestException)), [phase_step.ACT__PARSE] + SYMBOL_VALIDATION_STEPS__ONCE + [ phase_step.SETUP__VALIDATE_PRE_SDS, phase_step.ACT__VALIDATE_PRE_SDS, ], ))
def runTest(self): conf = self.configuration test_case = TestCaseGeneratorWithExtraInstrsBetweenRecordingInstr() \ .add(conf.phase, conf.instruction_that_raises(test.ImplementationErrorTestException())) execute_test_case_with_recording( self, Arrangement(test_case), Expectation( asrt_result.matches2( ExecutionFailureStatus.INTERNAL_ERROR, asrt_result.has_sds(), asrt_result.has_no_action_to_check_outcome(), ExpectedFailureForInstructionFailure.new_with_exception( conf.step, test_case.the_extra(conf.phase)[0].source, test.ImplementationErrorTestException), ), conf.expected_steps, ))
def test_internal_error_in_validate_symbols(self): test_case = _single_successful_instruction_in_each_phase() self._check( Arrangement(test_case, atc_symbol_usages=do_raise( test.ImplementationErrorTestException())), Expectation( asrt_result.matches2( ExecutionFailureStatus.INTERNAL_ERROR, asrt_result.has_no_sds(), asrt_result.has_no_action_to_check_outcome(), ExpectedFailureForPhaseFailure.new_with_exception( phase_step.ACT__VALIDATE_SYMBOLS, test.ImplementationErrorTestException)), [ phase_step.ACT__PARSE, phase_step.SETUP__VALIDATE_SYMBOLS, phase_step.ACT__VALIDATE_SYMBOLS, ], ))
def validator_that_raises_exception() -> Optional[TextRenderer]: raise test.ImplementationErrorTestException()