예제 #1
0
 def _result_for_unexpected_type(
         self,
         actual: Optional[file_properties.FileType]) -> MatchingResult:
     actual_type_description = (
         'unknown' if actual is None else
         file_properties.TYPE_INFO[actual].description)
     tb = self.__tb_with_expected().append_details(
         custom_details.actual(details.String(actual_type_description)))
     return tb.build_result(False)
예제 #2
0
 def matches_w_trace(self, model: StringSource) -> MatchingResult:
     first_line = self._first_line(model)
     if first_line != '':
         return (self._new_tb().append_details(
             custom_details.actual(
                 details.String(repr(first_line) +
                                '...'))).build_result(False))
     else:
         return self._new_tb().build_result(True)
예제 #3
0
    def _trace_builder(self, actual: str) -> TraceBuilder:
        ret_val = TraceBuilder(self.name)

        ret_val.append_details(
            custom_details.expected(details.String(repr(self._expected))))
        ret_val.append_details(
            custom_details.actual(details.String(repr(actual))))

        return ret_val
예제 #4
0
 def _all_match(self, tb: TraceBuilder,
                tot_num_elements: int) -> MatchingResult:
     actual = details.String(
         str_constructor.FormatPositional(
             'Every {} matches ({} tested)',
             self._conf.setup.rendering.type_name,
             tot_num_elements,
         ))
     expected = custom_details.TreeStructure(
         self._conf.predicate.structure())
     return (tb.append_details(
         custom_details.expected(expected)).append_details(
             custom_details.actual(actual)).build_result(True))
예제 #5
0
    def _report_final_element(self, tb: TraceBuilder, result: MatchingResult,
                              element: ELEMENT) -> MatchingResult:
        header = (self._matching_element_header()
                  if result.value else self._non_matching_element_header())
        actual = custom_details.actual(
            details.HeaderAndValue(
                header,
                self._conf.setup.rendering.renderer(element),
            ))
        tb.append_details(actual)

        tb.append_child(result.trace)

        return tb.build_result(result.value)
예제 #6
0
    def matches_w_trace(self, model: str) -> MatchingResult:
        tb = self._new_tb_with_expected().append_details(
            custom_details.actual(
                custom_details.StringAsSingleLineWithMaxLenDetailsRenderer(model))
        )

        match = self._find_match(model)

        if match is not None:
            tb.append_details(
                custom_details.match(custom_details.PatternMatchRenderer(match))
            )

        return tb.build_result(match is not None)
예제 #7
0
 def matches_w_trace(self, model: MODEL) -> MatchingResult:
     tb = self._new_tb_with_expected().append_details(
         custom_details.actual(
             details.String(str_constructor.Repr(str(model)))))
     return tb.build_result(self._matcher(model, self._glob_pattern))