def test_not_matches(self): cases = [ NEA( 'actual is empty list of line elements', expected=sut.matches_major_block( asrt.not_(asrt.is_empty_sequence)), actual=MajorBlock([]), ), NEA( 'actual element is unexpected', expected=sut.matches_major_block( asrt.matches_sequence( [asrt.not_(asrt.is_instance(MinorBlock))])), actual=MajorBlock([MinorBlock([])]), ), NEA( 'unexpected element properties', expected=sut.matches_major_block( asrt.anything_goes(), properties=asrt.not_(asrt.is_instance(ElementProperties))), actual=MajorBlock( [MinorBlock([], ELEMENT_PROPERTIES__NEUTRAL)]), ), ] for case in cases: with self.subTest(case.name): assert_that_assertion_fails(case.expected, case.actual)
def test_not_matches(self): cases = [ NIE( 'default assertion/not a renderer', input_value=MajorBlock([]), expected_value=sut.is_renderer_of_major_blocks(), ), NIE( 'default assertion/not a sequence', input_value=rend_comb.ConstantR(MajorBlock([])), expected_value=sut.is_renderer_of_major_blocks(), ), NIE( 'default assertion/not a major block', input_value=rend_comb.ConstantSequenceR([MinorBlock([])]), expected_value=sut.is_renderer_of_major_blocks(), ), NIE( 'default assertion/invalid contents of block', input_value=rend_comb.ConstantSequenceR( [MajorBlock(['not a minor block'])]), expected_value=sut.is_renderer_of_major_blocks(), ), NIE( 'custom assertion/unexpected number of blocks', input_value=rend_comb.ConstantSequenceR([]), expected_value=sut.is_renderer_of_major_blocks( asrt.len_equals(1)), ), ] for case in cases: with self.subTest(case.name): assert_that_assertion_fails(case.expected_value, case.input_value)
def test_matches(self): cases = [ NEA( 'empty list of blocks', expected=sut.matches_major_block(asrt.is_empty_sequence), actual=MajorBlock([]), ), NEA( 'non-empty list of blocks', expected=sut.matches_major_block( asrt.matches_sequence([asrt.is_instance(MinorBlock)])), actual=MajorBlock([MinorBlock([])]), ), NEA( 'test of element properties', expected=sut.matches_major_block( asrt.anything_goes(), properties=sut.matches_element_properties( indentation=sut.matches_indentation( level=asrt.equals(72))), ), actual=MajorBlock([], ElementProperties(Indentation(72, ''), TEXT_STYLE__NEUTRAL)), ), ] for case in cases: with self.subTest(case.name): case.expected.apply_without_message(self, case.actual)
def render(self) -> MajorBlock: return MajorBlock([ MinorBlock([ struct.LineElement( struct.StringLineObject(self._single_line_info_str())), ]) ])
def test_not_matches(self): cases = [ NIE( 'default assertion/not a renderer', input_value=self._LINE_ELEMENT, expected_value=sut.is_renderer_of_line_elements(), ), NIE( 'default assertion/not a sequence', input_value=rend_comb.ConstantR(self._LINE_ELEMENT), expected_value=sut.is_renderer_of_line_elements(), ), NIE( 'default assertion/not a line element', input_value=rend_comb.ConstantSequenceR([MajorBlock([])]), expected_value=sut.is_renderer_of_line_elements(), ), NIE( 'default assertion/invalid contents of line element', input_value=rend_comb.ConstantSequenceR([ LineElement(StringLineObject('string'), 'not properties') ]), expected_value=sut.is_renderer_of_line_elements(), ), NIE( 'custom assertion/unexpected number of blocks', input_value=rend_comb.ConstantSequenceR([]), expected_value=sut.is_renderer_of_line_elements( asrt.len_equals(1)), ), ] for case in cases: with self.subTest(case.name): assert_that_assertion_fails(case.expected_value, case.input_value)
def _visit_message(self, ed: error_description.ErrorDescriptionOfMessage) -> Sequence[MajorBlock]: message_blocks = self._message_blocks(ed) return ( [MajorBlock(message_blocks)] if message_blocks else [] )
def _visit_exception(self, ed: error_description.ErrorDescriptionOfException) -> Sequence[MajorBlock]: minor_blocks = self._message_blocks(ed) minor_blocks.append( struct.minor_block_from_lines([ struct.StringLineObject('Exception:'), struct.PreFormattedStringLineObject(str(ed.exception), False), ]) ) return [MajorBlock(minor_blocks)]
def render(self) -> MajorBlock: def_report_infos = map(mk_single_def_report_info, self.definitions) definition_lines = _get_list_lines(def_report_infos) return MajorBlock([ structure.MinorBlock([ structure.LineElement( structure.StringLinesObject(definition_lines) ) ]) ])
def test_matches(self): cases = [ NIE( 'default assertion/empty list of blocks', input_value=rend_comb.ConstantSequenceR([]), expected_value=sut.is_renderer_of_major_blocks(), ), NIE( 'default assertion/non-empty list of blocks', input_value=rend_comb.ConstantSequenceR([MajorBlock([])]), expected_value=sut.is_renderer_of_major_blocks(), ), NIE( 'custom assertion', input_value=rend_comb.ConstantSequenceR([MajorBlock([])]), expected_value=sut.is_renderer_of_major_blocks( asrt.len_equals(1)), ), ] for case in cases: with self.subTest(case.name): case.expected_value.apply_without_message( self, case.input_value)
def _visit_external_process_error(self, ed: error_description.ErrorDescriptionOfExternalProcessError ) -> Sequence[MajorBlock]: minor_blocks = self._message_blocks(ed) lines = [struct.StringLineObject(misc_texts.EXIT_CODE_TITLE + ': ' + str(ed.external_process_error.exit_code))] if ed.external_process_error.stderr_output: lines.append(struct.PreFormattedStringLineObject(ed.external_process_error.stderr_output, False)) minor_blocks.append( struct.minor_block_from_lines(lines) ) return [MajorBlock(minor_blocks)]
def _exception_blocks(self) -> List[MajorBlock]: if not self._failure_details.has_exception: return [] ex = self._failure_details.exception return [ MajorBlock([ struct.minor_block_from_lines([ struct.StringLineObject('Exception'), ]), struct.minor_block_from_lines([ struct.PreFormattedStringLineObject(str(ex), False), ]), ]) ]
def render(self) -> MajorBlock: minor_blocks_renderer = HeaderAndPathMinorBlocks( self._header, self._path, self._explanation) return MajorBlock(minor_blocks_renderer.render_sequence())
def render(self) -> MajorBlock: return MajorBlock( self._contents.render_sequence(), self._properties, )
def render(self) -> MajorBlock: return MajorBlock(TreeRendererToMinorBlocks(self._configuration, self._tree).render_sequence())