def test_middle_instruction_fails(self):
     recording_media = RecordingMedia()
     instruction_executor = InstructionExecutorThatRecordsInstructionNameAndFailsFor(
         instruction_with_name('Middle instruction'),
         recording_media.new_recorder_with_header('instruction executor'),
         PartialInstructionControlledFailureInfo(
             PartialControlledFailureEnum.FAIL,
             asrt_text_doc.new_single_string_text_for_test('fail message')))
     phase_contents = SectionContents((
         new_instruction_element(Line(1, '1'),
                                 TestInstruction('First instruction')),
         new_instruction_element(Line(2, '2'),
                                 TestInstruction('Middle instruction')),
         new_instruction_element(Line(3, '3'),
                                 TestInstruction('Last instruction')),
     ))
     self._standard_test(
         recording_media, phase_contents, instruction_executor,
         asrt_failure.is_present_with(
             ExecutionFailureStatus.FAIL,
             equals_single_line_source_location_path(Line(2, '2')),
             asrt_failure_details.is_failure_message_of('fail message')), [
                 'instruction header for source line number: 1',
                 'instruction executor: First instruction',
                 'instruction header for source line number: 2',
                 'instruction executor: Middle instruction',
             ])
 def test_matches(self):
     message_str = 'message'
     cases = [
         NEA('equals',
             expected=
             sut.is_failure_message_of(message_str),
             actual=
             FailureDetails.new_constant_message(message_str),
             ),
     ]
     for case in cases:
         with self.subTest(case.name):
             case.expected.apply_without_message(self, case.actual)
 def test_not_matches(self):
     cases = [
         NEA('not a ' + str(FailureDetails),
             expected=
             sut.is_failure_message_of(''),
             actual=
             'not a ' + str(FailureDetails),
             ),
         NEA('message is absent',
             expected=
             sut.is_failure_message_of(''),
             actual=
             FailureDetails.new_exception(ValueError('an exception')),
             ),
         NEA('unexpected message',
             expected=
             sut.is_failure_message_of('expected'),
             actual=
             FailureDetails.new_constant_message('actual'),
             ),
     ]
     for case in cases:
         with self.subTest(case.name):
             assert_that_assertion_fails(case.expected, case.actual)
 def test_single_failing_instruction_executor__status_hard_error(self):
     recording_media = RecordingMedia()
     instruction_executor = InstructionExecutorThatRecordsInstructionNameAndFailsFor(
         any_instruction,
         recording_media.new_recorder_with_header('instruction executor'),
         PartialInstructionControlledFailureInfo(
             PartialControlledFailureEnum.HARD_ERROR,
             asrt_text_doc.new_single_string_text_for_test(
                 'hard error message')))
     phase_contents = SectionContents(
         (new_instruction_element(Line(1, '1'),
                                  TestInstruction('The instruction')), ))
     self._standard_test(
         recording_media, phase_contents, instruction_executor,
         asrt_failure.is_present_with(
             ExecutionFailureStatus.HARD_ERROR,
             equals_single_line_source_location_path(Line(1, '1')),
             asrt_failure_details.is_failure_message_of(
                 'hard error message')), [
                     'instruction header for source line number: 1',
                     'instruction executor: The instruction'
                 ])
Example #5
0
 def new_with_message(phase_step: SimplePhaseStep,
                      source: line_source.LineSequence,
                      error_message: str) -> Assertion[FailureInfo]:
     return ExpectedFailureForInstructionFailure(
         phase_step, source,
         asrt_failure_details.is_failure_message_of(error_message))
Example #6
0
 def new_with_message(phase_step: SimplePhaseStep,
                      error_message: str) -> Assertion[FailureInfo]:
     return ExpectedFailureForPhaseFailure(
         phase_step,
         asrt_failure_details.is_failure_message_of(error_message))