예제 #1
0
def _suite_read_error_renderer(ex: SuiteReadError) -> SequenceRenderer[MajorBlock]:
    blocks_renderers = [
        source_location.location_blocks_renderer(ex.source_location,
                                                 ex.maybe_section_name,
                                                 None),
        _error_message_blocks__read_error(ex),
    ]
    return comb.ConcatenationR(blocks_renderers)
예제 #2
0
    def render_sequence(self) -> Sequence[MajorBlock]:
        renderers = [
            source_location.location_blocks_renderer(
                self._error_info.source_location_path,
                self._error_info.maybe_section_name, None),
            error_description.ErrorDescriptionRenderer(
                self._error_info.description),
        ]

        return comb.ConcatenationR(renderers).render_sequence()
예제 #3
0
    def test_with_source(self):
        # ARRANGE #
        section_name = 'section-name'
        line_sequence_a = LineSequence(2, ['source a 1', 'source a 2'])
        file_path_a = pathlib.Path('file-a.src')

        minor_blocks_expectation = asrt.matches_sequence([
            _matches_plain_minor_block_w_single_plain_line(
                section_line(section_name)),
            _matches_plain_minor_block_w_single_plain_line(
                file_and_line_num_line(file_path_a, line_sequence_a)),
            matches_source_code_minor_block(line_sequence_a.lines),
        ])
        input_value = SourceLocationPath(location=SourceLocation(
            line_sequence_a, file_path_a),
                                         file_inclusion_chain=[])

        with self.subTest(blocks_rendering='minor blocks'):
            # ACT #
            actual_renderer = source_location.location_minor_blocks_renderer(
                input_value, section_name, None)
            actual = actual_renderer.render_sequence()
            # ASSERT #
            minor_blocks_expectation.apply_without_message(self, actual)

        with self.subTest(blocks_rendering='major blocks'):
            expected_major_blocks = asrt.matches_sequence([
                asrt_struct.matches_major_block__w_plain_properties(
                    minor_blocks=minor_blocks_expectation)
            ])
            # ACT #
            actual_renderer = source_location.location_blocks_renderer(
                input_value, section_name, None)
            actual = actual_renderer.render_sequence()
            # ASSERT #
            expected_major_blocks.apply_without_message(self, actual)
예제 #4
0
 def visit_instruction_failure(self, failure_info: InstructionFailureInfo) -> SequenceRenderer[MajorBlock]:
     return source_location.location_blocks_renderer(
         failure_info.source_location,
         failure_info.phase_step.phase.identifier,
         failure_info.element_description
     )