Ejemplo n.º 1
0
 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',
             ])
Ejemplo n.º 2
0
 def test_last_instruction_fails(self):
     recording_media = RecordingMedia()
     instruction_executor = InstructionExecutorThatRecordsInstructionNameAndFailsFor(
         instruction_with_name('Last instruction'),
         recording_media.new_recorder_with_header('instruction executor'),
         PartialInstructionControlledFailureInfo(PartialControlledFailureEnum.FAIL,
                                                 'fail message')
     )
     phase_contents = SectionContents((new_instruction_element(Line(1, '1'),
                                                               TestInstruction('First instruction')),
                                       new_instruction_element(Line(2, '2'),
                                                               TestInstruction('Last instruction'))
                                       ))
     self._standard_test(
         recording_media,
         phase_contents,
         instruction_executor,
         asrt_failure.is_present_with(PartialExeResultStatus.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: Last instruction',
          ])
Ejemplo n.º 3
0
 def test_single_exception_raising_instruction_executor(self):
     recording_media = RecordingMedia()
     instruction_executor = InstructionExecutorThatRecordsInstructionNameAndRaisesExceptionFor(
         any_instruction,
         recording_media.new_recorder_with_header('instruction executor'),
         TestException())
     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.INTERNAL_ERROR,
             equals_single_line_source_location_path(Line(1, '1')),
             asrt_failure_details.is_exception_of_type(TestException)), [
                 'instruction header for source line number: 1',
                 'instruction executor: The instruction'
             ])
Ejemplo n.º 4
0
 def test_single_exception_raising_instruction_executor(self):
     recording_media = RecordingMedia()
     instruction_executor = InstructionExecutorThatRecordsInstructionNameAndRaisesExceptionFor(
         any_instruction,
         recording_media.new_recorder_with_header('instruction executor'),
         TestException()
     )
     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(PartialExeResultStatus.IMPLEMENTATION_ERROR,
                                      equals_single_line_source_location_path(Line(1, '1')),
                                      asrt_failure_details.is_exception(TestException)),
         ['instruction header for source line number: 1',
          'instruction executor: The instruction'])
Ejemplo n.º 5
0
 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,
                                                 '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(PartialExeResultStatus.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'])
Ejemplo n.º 6
0
 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'
                 ])