コード例 #1
0
ファイル: instruction.py プロジェクト: emilkarlen/exactly
    def test_hard_error(self):
        the_instruction_environment = instruction_environment.fake_post_sds_environment()
        the_os_services = os_services.new_default()

        cases = [
            (
                'hard error exception in left operand',
                asrt_pfh.is_hard_error(asrt.equals('error error in left op')),

                operand_resolver_that(
                    resolve_return_value_action=actions.do_raise(PfhHardErrorException('error error in left op'))),
                operand_resolver_that(),
            ),
            (
                'hard error exception in right operand',
                asrt_pfh.is_hard_error(asrt.equals('error error in right op')),

                operand_resolver_that(),
                operand_resolver_that(
                    resolve_return_value_action=actions.do_raise(PfhHardErrorException('error error in right op'))),
            ),
        ]

        for name, result_assertion, l_op, r_op in cases:
            instruction_to_check = sut.Instruction(cmp_setup(l_op, r_op))
            with self.subTest(name=name):
                # ACT #

                actual = instruction_to_check.main(the_instruction_environment,
                                                   the_os_services)

                # ASSERT #

                result_assertion.apply_without_message(self, actual)
コード例 #2
0
    def new_w_defaults_of_hard_error(
        may_depend_on_external_resources: bool,
        as_str: Callable[[], str] = do_raise(
            HardErrorException(
                asrt_text_doc.new_single_string_text_for_test(
                    'should not be called'))),
        as_lines: Callable[[], Iterator[str]] = do_raise(
            HardErrorException(
                asrt_text_doc.new_single_string_text_for_test(
                    'should not be called'))),
        as_file: Callable[[DirFileSpace], Path] = do_raise(
            HardErrorException(
                asrt_text_doc.new_single_string_text_for_test(
                    'should not be called'))),
        write_to: Callable[[TextIO], None] = do_raise(
            HardErrorException(
                asrt_text_doc.new_single_string_text_for_test(
                    'should not be called'))),
    ) -> 'StringSourceContentsData':
        def _may_depend_on_external_resources() -> bool:
            return may_depend_on_external_resources

        return StringSourceContentsData(
            may_depend_on_external_resources=_may_depend_on_external_resources,
            as_str=as_str,
            as_lines=as_lines,
            as_file=as_file,
            write_to=write_to,
        )
コード例 #3
0
 def __init__(self,
              resolving_dependencies: Set[DirectoryStructurePartition],
              get_value_when_no_dir_dependencies=do_raise(_ShouldNotBeInvokedTestException()),
              get_value_of_any_dependency=do_raise(_ShouldNotBeInvokedTestException()),
              ):
     super().__init__(resolving_dependencies,
                      None,
                      get_value_when_no_dir_dependencies,
                      get_value_of_any_dependency)
コード例 #4
0
 def __init__(self,
              resolving_dependency: Optional[DirectoryStructurePartition],
              value_when_no_dir_dependencies=do_raise(_ShouldNotBeInvokedTestException()),
              value_pre_sds=do_raise(_ShouldNotBeInvokedTestException()),
              value_post_sds=do_raise(_ShouldNotBeInvokedTestException()),
              ):
     self._resolving_dependency = resolving_dependency
     self._value_when_no_dir_dependencies = value_when_no_dir_dependencies
     self._value_pre_sds = value_pre_sds
     self._value_post_sds = value_post_sds
コード例 #5
0
ファイル: instruction.py プロジェクト: emilkarlen/exactly
    def test_validation_pre_sds(self):
        the_instruction_environment = instruction_environment.fake_pre_sds_environment()

        cases = [
            (
                'validation should succeed when both operands succeed',
                asrt_svh.is_success(),

                operand_resolver_that(),
                operand_resolver_that(),
            ),
            (
                'validation exception in left operand',
                asrt_svh.is_validation_error(asrt.equals('error in left op')),

                operand_resolver_that(
                    validate_pre_sds=actions.do_raise(SvhValidationException('error in left op'))),
                operand_resolver_that(),
            ),
            (
                'validation exception in right operand',
                asrt_svh.is_validation_error(asrt.equals('error in right op')),

                operand_resolver_that(),
                operand_resolver_that(
                    validate_pre_sds=actions.do_raise(SvhValidationException('error in right op'))),
            ),
            (
                'hard error exception in left operand',
                asrt_svh.is_hard_error(asrt.equals('error in left op')),

                operand_resolver_that(
                    validate_pre_sds=actions.do_raise(SvhHardErrorException('error in left op'))),
                operand_resolver_that(),
            ),
            (
                'hard error exception in right operand',
                asrt_svh.is_hard_error(asrt.equals('error in right op')),

                operand_resolver_that(),
                operand_resolver_that(
                    validate_pre_sds=actions.do_raise(SvhHardErrorException('error in right op'))),
            ),
        ]

        for name, result_assertion, l_op, r_op in cases:
            instruction_to_check = sut.Instruction(cmp_setup(l_op, r_op))
            with self.subTest(name=name):
                # ACT #

                actual = instruction_to_check.validate_pre_sds(the_instruction_environment)

                # ASSERT #

                result_assertion.apply_without_message(self, actual)
コード例 #6
0
 def __init__(
     self,
     resolving_dependencies: Set[DirectoryStructurePartition],
     get_value_when_no_dir_dependencies=do_raise(
         _ShouldNotBeInvokedTestException()),
     get_value_of_any_dependency=do_raise(
         _ShouldNotBeInvokedTestException()),
 ):
     super().__init__(resolving_dependencies, None,
                      get_value_when_no_dir_dependencies,
                      get_value_of_any_dependency)
コード例 #7
0
 def __init__(
     self,
     resolving_dependencies: Set[DirectoryStructurePartition],
     get_value_when_no_dir_dependencies: Callable[[], Any] = do_raise(
         _ShouldNotBeInvokedTestException()),
     get_value_of_any_dependency: Callable[[TestCaseDs], Any] = do_raise(
         _ShouldNotBeInvokedTestException()),
 ):
     self._resolving_dependencies = resolving_dependencies
     self._get_value_when_no_dir_dependencies = get_value_when_no_dir_dependencies
     self._get_value_of_any_dependency = get_value_of_any_dependency
コード例 #8
0
 def __init__(
         self,
         resolving_dependency: Optional[DirectoryStructurePartition],
         value_when_no_dir_dependencies=do_raise(
             _ShouldNotBeInvokedTestException()),
         value_pre_sds=do_raise(_ShouldNotBeInvokedTestException()),
         value_post_sds=do_raise(_ShouldNotBeInvokedTestException()),
 ):
     self._resolving_dependency = resolving_dependency
     self._value_when_no_dir_dependencies = value_when_no_dir_dependencies
     self._value_pre_sds = value_pre_sds
     self._value_post_sds = value_post_sds
コード例 #9
0
    def __init__(self,
                 resolving_dependencies: Set[DirectoryStructurePartition],

                 get_value_when_no_dir_dependencies: Callable[[], Any] =
                 do_raise(_ShouldNotBeInvokedTestException()),

                 get_value_of_any_dependency: Callable[[HomeAndSds], Any] =
                 do_raise(_ShouldNotBeInvokedTestException()),
                 ):
        self._resolving_dependencies = resolving_dependencies
        self._get_value_when_no_dir_dependencies = get_value_when_no_dir_dependencies
        self._get_value_of_any_dependency = get_value_of_any_dependency
コード例 #10
0
ファイル: other_scenarios.py プロジェクト: emilkarlen/exactly
    def test_implementation_error_in_setup_main_step(self):
        test_case = TestCaseGeneratorWithExtraInstrsBetweenRecordingInstr() \
            .add(PartialPhase.SETUP,
                 test.setup_phase_instruction_that(
                     main=do_raise(test.ImplementationErrorTestException())))
        self._check(
            Arrangement(test_case,
                        act_executor_execute=execute_action_that_returns_exit_code(5)),
            Expectation(
                asrt_result.matches2(
                    PartialExeResultStatus.IMPLEMENTATION_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),
                 ],
            ))
コード例 #11
0
ファイル: other_scenarios.py プロジェクト: emilkarlen/exactly
 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),
             ],
         ))
コード例 #12
0
 def test_fail_due_to_unexpected_hard_error_exception(self):
     self._check_source_and_exe_variants__failing_assertions(
         ParserThatGives(instruction_embryo_that__phase_agnostic(
             main=do_raise(HardErrorException(new_single_string_text_for_test('hard error message'))))
         ),
         Arrangement.phase_agnostic(),
         MultiSourceExpectation.phase_agnostic(
             main_result=asrt.anything_goes()
         ),
     )
コード例 #13
0
 def new_w_defaults_of_not_impl(
     may_depend_on_external_resources: Callable[[], bool] = do_raise(
         ValueError('should not be called')),
     as_str: Callable[[],
                      str] = do_raise(ValueError('should not be called')),
     as_lines: Callable[[], Iterator[str]] = do_raise(
         ValueError('should not be called')),
     as_file: Callable[[DirFileSpace],
                       Path] = do_raise(ValueError('should not be called')),
     write_to: Callable[[TextIO], None] = do_raise(
         ValueError('should not be called')),
 ) -> 'StringSourceContentsData':
     return StringSourceContentsData(
         may_depend_on_external_resources=may_depend_on_external_resources,
         as_str=as_str,
         as_lines=as_lines,
         as_file=as_file,
         write_to=write_to,
     )
コード例 #14
0
 def test_succeed_due_to_expected_hard_error_exception(self):
     self._check_source_and_exe_variants(
         ParserThatGives(instruction_embryo_that__phase_agnostic(
             main=do_raise(HardErrorException(new_single_string_text_for_test('hard error message'))))
         ),
         Arrangement.phase_agnostic(),
         MultiSourceExpectation.phase_agnostic(
             main_raises_hard_error=True
         ),
     )
コード例 #15
0
 def new_w_default_to_raise_exception(
         constant_action: Callable[[bool], T] =
         do_raise(ValueError('constant method must not be invoked')),
         negation_action: Callable[[MatcherWTrace[MODEL]], T] =
         do_raise(ValueError('negation method must not be invoked')),
         conjunction_action: Callable[[Sequence[MatcherWTrace[MODEL]]], T] =
         do_raise(ValueError('conjunction method must not be invoked')),
         disjunction_action: Callable[[Sequence[MatcherWTrace[MODEL]]], T] =
         do_raise(ValueError('disjunction method must not be invoked')),
         non_standard_action: Callable[[MatcherWTrace[MODEL]], T] =
         do_raise(ValueError('non_standard method must not be invoked')),
 ) -> MatcherStdTypeVisitor[MODEL, T]:
     return MatcherStdTypeVisitorTestAcceptImpl(
         constant_action,
         negation_action,
         conjunction_action,
         disjunction_action,
         non_standard_action,
     )
コード例 #16
0
ファイル: atc_execution.py プロジェクト: emilkarlen/exactly
 def test_WHEN_parse_raises_unknown_exception_THEN_execution_SHOULD_stop_with_result_of_internal_error(
         self):
     # ARRANGE #
     step_recorder = ListRecorder()
     recording_atc = ActionToCheckWrapperThatRecordsSteps(
         step_recorder, _atc_that_does_nothing())
     actor = ActorForConstantAtc(recording_atc,
                                 parse_atc=do_raise(
                                     ValueError('failure message')))
     arrangement = Arrangement(test_case=_empty_test_case(), actor=actor)
     # ASSERT #
     expectation = Expectation(phase_result=asrt_result.status_is(
         ExecutionFailureStatus.INTERNAL_ERROR))
     # APPLY #
     execute_and_check(self, arrangement, expectation)
     self.assertEqual([], step_recorder.recorded_elements, 'executed steps')
コード例 #17
0
ファイル: xfail.py プロジェクト: emilkarlen/exactly
 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),
             ],
         ))
コード例 #18
0
ファイル: xfail.py プロジェクト: emilkarlen/exactly
    def test_with_implementation_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.IMPLEMENTATION_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),
                 ],
            ))
コード例 #19
0
ファイル: normal.py プロジェクト: emilkarlen/exactly
 def test_implementation_error_in_configuration_phase(self):
     test_case = test_case_with_two_instructions_in_each_phase() \
         .add(phase_identifier.CONFIGURATION,
              test.configuration_phase_instruction_that(
                  main=do_raise(test.ImplementationErrorTestException())))
     self._check(
         Arrangement(test_case),
         Expectation(
             asrt_result.matches2(
                 FullExeResultStatus.IMPLEMENTATION_ERROR,
                 asrt_result.has_no_sds(),
                 asrt_result.has_no_action_to_check_outcome(),
                 ExpectedFailureForInstructionFailure.new_with_exception(
                     phase_step.CONFIGURATION__MAIN,
                     test_case.the_extra(phase_identifier.CONFIGURATION)[0].source,
                     test.ImplementationErrorTestException),
             ),
             [phase_step.CONFIGURATION__MAIN],
         ))
コード例 #20
0
 def test_implementation_error_in_validate_symbols(self):
     test_case = _single_successful_instruction_in_each_phase()
     self._check(
         Arrangement(test_case,
                     act_executor_symbol_usages=do_raise(test.ImplementationErrorTestException())),
         Expectation(
             asrt_result.matches2(PartialExeResultStatus.IMPLEMENTATION_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,
             ],
         ))
コード例 #21
0
ファイル: atc_execution.py プロジェクト: emilkarlen/exactly
 def test_WHEN_parse_raises_unknown_exception_THEN_execution_SHOULD_stop_with_result_of_implementation_error(self):
     # ARRANGE #
     expected_cause = svh.new_svh_validation_error('failure message')
     atc_that_does_nothing = ActionToCheckThatRunsConstantActions()
     step_recorder = ListRecorder()
     recording_atc = ActionToCheckWrapperThatRecordsSteps(step_recorder,
                                                          atc_that_does_nothing)
     actor = ActorForConstantAtc(
         recording_atc,
         parse_atc=do_raise(ValueError(expected_cause))
     )
     arrangement = Arrangement(test_case=_empty_test_case(),
                               actor=actor)
     # ASSERT #
     expectation = Expectation(phase_result=asrt_result.status_is(PartialExeResultStatus.IMPLEMENTATION_ERROR))
     # APPLY #
     execute_and_check(self, arrangement, expectation)
     self.assertEqual([],
                      step_recorder.recorded_elements,
                      'executed steps')
コード例 #22
0
 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,
             ],
         ))
コード例 #23
0
ファイル: other_scenarios.py プロジェクト: emilkarlen/exactly
 def test_hard_error_exception(self):
     test_case = TestCaseGeneratorWithExtraInstrsBetweenRecordingInstr() \
         .add(PartialPhase.CLEANUP,
              test.cleanup_phase_instruction_that(
                  main=do_raise(hard_error_ex('hard error exception msg from CLEANUP'))))
     self._check(
         Arrangement(test_case,
                     atc_execute=execute_action_that_returns_exit_code(3)),
         Expectation(
             asrt_result.matches2(
                 ExecutionFailureStatus.HARD_ERROR,
                 asrt_result.has_sds(),
                 asrt_result.has_action_to_check_outcome_with_exit_code(3),
                 ExpectedFailureForInstructionFailure.new_with_message(
                     phase_step.CLEANUP__MAIN,
                     test_case.the_extra(PartialPhase.CLEANUP)[0].source,
                     'hard error exception msg from CLEANUP'),
             ),
             [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__VALIDATE_EXE_INPUT,
                 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),
             ],
         ))
コード例 #24
0
ファイル: main.py プロジェクト: emilkarlen/exactly
    def test_hard_error_exception_from_executor_execute_SHOULD_be_handled(
            self):
        # ARRANGE #
        act_phase_instructions = []
        hard_error_message = 'the err msg'

        actor = sut.ActorFromParts(
            ParserWithConstantResult(SymbolUserWithConstantSymbolReferences(
                ())),
            sut.UnconditionallySuccessfulValidatorConstructor(),
            _ExecutorConstructorForConstant(
                ExecutorThat(execute_initial_action=do_raise(
                    HardErrorException(
                        asrt_text_doc.new_single_string_text_for_test(
                            hard_error_message))))),
        )

        arrangement = arrangement_w_tcds()
        expectation = Expectation.hard_error_from_execute(
            error_message=asrt_text_doc.
            is_single_pre_formatted_text_that_equals(hard_error_message))
        # ACT & ASSERT #
        check_execution(self, actor, act_phase_instructions, arrangement,
                        expectation)
コード例 #25
0
ファイル: other_scenarios.py プロジェクト: emilkarlen/exactly
 def test_hard_error_exception(self):
     test_case = TestCaseGeneratorWithExtraInstrsBetweenRecordingInstr() \
         .add(PartialPhase.SETUP,
              test.setup_phase_instruction_that(
                  main=do_raise(hard_error_ex('hard error exception msg from setup'))))
     self._check(
         Arrangement(test_case),
         Expectation(
             asrt_result.matches2(
                 ExecutionFailureStatus.HARD_ERROR,
                 asrt_result.has_sds(),
                 asrt_result.has_no_action_to_check_outcome(),
                 ExpectedFailureForInstructionFailure.new_with_message(
                     phase_step.SETUP__MAIN,
                     test_case.the_extra(PartialPhase.SETUP)[0].source,
                     'hard error exception msg from setup'),
             ),
             [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),
             ],
         ))
コード例 #26
0
 def before_assert_instr_setup(self) -> SingleInstructionSetup:
     return instr_setup(
         instr.before_assert_phase_instruction_that(
             main_initial_action=do_raise(ImplementationError())))
コード例 #27
0
 def cleanup_instr_setup(self) -> SingleInstructionSetup:
     return instr_setup(
         instr.cleanup_phase_instruction_that(
             main_initial_action=do_raise(ImplementationError())))
コード例 #28
0
 def instruction_that_raises(self, exception: Exception) -> TestCaseInstruction:
     return test.before_assert_phase_instruction_that(validate_post_setup=do_raise(exception))
コード例 #29
0
ファイル: processors.py プロジェクト: emilkarlen/exactly
 def before_assert_instr_setup(self) -> SingleInstructionSetup:
     return instr_setup(instr.before_assert_phase_instruction_that(
         main_initial_action=do_raise(ImplementationError())
     ))
コード例 #30
0
 def instruction_that_raises(self, exception: Exception) -> TestCaseInstruction:
     return test.assert_phase_instruction_that(validate_pre_sds=do_raise(exception))
コード例 #31
0
 def instruction_that_raises(self,
                             exception: Exception) -> TestCaseInstruction:
     return test.before_assert_phase_instruction_that(
         validate_post_setup=do_raise(exception))
コード例 #32
0
 def instruction_that_raises(self, exception: Exception) -> TestCaseInstruction:
     return test.assert_phase_instruction_that(validate_pre_sds=do_raise(exception))
コード例 #33
0

def first_line_should_be_exit_identifier(put: unittest.TestCase, output: str,
                                         expected_exit_value: ExitValue):
    lines = output.split()
    put.assertTrue(
        len(lines) > 0,
        'There should be at least one line (found {})'.format(len(lines)))

    first_line = lines[0]

    put.assertEqual(expected_exit_value.exit_identifier, first_line,
                    'first line')


DO_RAISES_EXCEPTION = do_raise(ValueError('implementation error msg'))

SVH_VALIDATION_ERROR = do_return(
    svh.new_svh_validation_error__str('validation error msg'))
SVH_HARD_ERROR = do_return(svh.new_svh_hard_error__str('hard error msg'))

SH_HARD_ERROR = do_return(sh.new_sh_hard_error__str('hard error msg'))


def output_is_sds_which_should_be_preserved(
        sds_dir_name: str) -> Assertion[str]:
    return asrt.and_([
        IsExistingDir(sds_dir_name),
        asrt.equals(sds_dir_name + '\n'),
    ])
コード例 #34
0
 def instruction_that_raises(self, exception: Exception) -> TestCaseInstruction:
     return test.cleanup_phase_instruction_that(symbol_usages=do_raise(exception))
コード例 #35
0
ファイル: keep_sandbox.py プロジェクト: emilkarlen/exactly
def first_line_should_be_exit_identifier(put: unittest.TestCase,
                                         output: str,
                                         expected_exit_value: ExitValue):
    lines = output.split()
    put.assertTrue(len(lines) > 0,
                   'There should be at least one line (found {})'.format(len(lines)))

    first_line = lines[0]

    put.assertEqual(expected_exit_value.exit_identifier,
                    first_line,
                    'first line')


DO_RAISES_EXCEPTION = do_raise(ValueError('implementation error msg'))

SVH_VALIDATION_ERROR = do_return(svh.new_svh_validation_error('validation error msg'))
SVH_HARD_ERROR = do_return(svh.new_svh_hard_error('hard error msg'))

SH_HARD_ERROR = do_return(sh.new_sh_hard_error('hard error msg'))


def output_is_sds_which_should_be_preserved(sds_dir_name: str) -> ValueAssertion[str]:
    return asrt.and_([
        IsExistingDir(sds_dir_name),
        asrt.equals(sds_dir_name + '\n'),
    ])


def output_is_empty(sds_dir_name: str) -> ValueAssertion[str]:
コード例 #36
0
 def instruction_that_raises(self, exception: Exception) -> TestCaseInstruction:
     return test.before_assert_phase_instruction_that(symbol_usages=do_raise(exception))
コード例 #37
0
ファイル: processors.py プロジェクト: emilkarlen/exactly
 def cleanup_instr_setup(self) -> SingleInstructionSetup:
     return instr_setup(instr.cleanup_phase_instruction_that(
         main_initial_action=do_raise(ImplementationError())
     ))
コード例 #38
0
 def instruction_that_raises(self, exception: Exception) -> TestCaseInstruction:
     return test.before_assert_phase_instruction_that(symbol_usages=do_raise(exception))
コード例 #39
0
 def instruction_that_raises(self, exception: Exception) -> TestCaseInstruction:
     return test.cleanup_phase_instruction_that(symbol_usages=do_raise(exception))