Пример #1
0
    def render(self) -> Sequence[Detail]:
        ret_val = [tree.StringDetail(self._path.value.render())]
        if self._path.resolving_dependency is DirectoryStructurePartition.HDS:
            ret_val.append(
                tree.IndentedDetail(
                    (tree.StringDetail(self._path.primitive.render()), )))

        return ret_val
Пример #2
0
 def __init__(self, result: bool):
     self._result = result
     self._matching_result = MatchingResult(
         self._result,
         renderers.Constant(
             tree.Node(logic.CONSTANT_MATCHER, self._result,
                       (tree.StringDetail(logic.BOOLEANS[result]), ), ())),
     )
     self._structure = renderers.Constant(
         tree.Node(logic.CONSTANT_MATCHER, None,
                   (tree.StringDetail(logic.BOOLEANS[result]), ), ()))
Пример #3
0
    def test(self):
        # ARRANGE #
        detail = sut.StringDetail('a detail')
        child = sut.Node('child header', False, (), ())
        root_header = 'root header'
        root_data = True
        root = sut.Node(root_header, root_data, (detail,), (child,))

        # ACT & ASSERT #

        self.assertEqual(root_header,
                         root.header,
                         'root header')

        self.assertEqual(root_data,
                         root.data,
                         'root data')

        expected_root_details = asrt.matches_singleton_sequence(
            asrt.is_(detail)
        )

        expected_root_details.apply_with_message(self,
                                                 root.details,
                                                 'root details')

        expected_root_children = asrt.matches_singleton_sequence(
            asrt.is_(child)
        )

        expected_root_children.apply_with_message(self,
                                                  root.children,
                                                  'root children')
Пример #4
0
 def render(self) -> Sequence[Detail]:
     s = self._value
     s = s[:self._max_chars_to_print]
     sr = repr(s)
     if len(s) != len(self._value):
         sr = sr + HAS_MORE_DATA_MARKER
     return [tree.StringDetail(sr)]
Пример #5
0
 def render(self) -> Sequence[Detail]:
     return [
         tree.StringDetail(' '.join([
             self._comparator.name,
             self._rhs.render(),
         ]))
     ]
Пример #6
0
 def render(self) -> tree.Node[None]:
     return tree.Node(
         self.NAME,
         None,
         [tree.StringDetail(argument)
          for argument in self._arguments],
         (),
     )
Пример #7
0
 def render(self) -> Sequence[Detail]:
     line = self._line
     return [
         tree.StringDetail(
             str_constructor.FormatPositional(
                 'Line {}. {}',
                 line[0],
                 repr(line[1]),
             ))
     ]
Пример #8
0
 def test_application(self):
     conf = self.configuration
     for value in [False, True]:
         conf.checker_for_parser_of_full_expr().check__w_source_variants(
             self,
             arguments=matcher_argument.Constant(value).as_arguments,
             input_=conf.arbitrary_model,
             arrangement=arrangement_wo_tcds(),
             expectation=Expectation(execution=ExecutionExpectation(
                 main_result=asrt_matching_result.matches(
                     asrt.equals(value),
                     trace=_utils.trace_equals(
                         tree.Node.leaf(logic.CONSTANT_MATCHER, value, (
                             tree.StringDetail(logic.BOOLEANS[value]),
                         )))))))
Пример #9
0
    def test_accept_visitor(self):
        # ARRANGE #

        visitor = _VisitorThatRegistersVisitedClassesAndReturnsConstant()

        detail = sut.StringDetail('the string')

        # ACT #

        detail.accept(visitor)

        # ASSERT #

        self.assertEqual(visitor.visited_classes,
                         [sut.StringDetail],
                         'visited classes')
Пример #10
0
    def test_attributes(self):
        # ARRANGE #
        header = 'the header'
        value = sut.StringDetail('the value detail header')
        detail = sut.HeaderAndValueDetail(header, [value])

        # ACT & ASSERT #

        self.assertIs(header,
                      detail.header,
                      'header')

        expected_values = asrt.matches_singleton_sequence(asrt.is_(value))

        expected_values.apply_with_message(self,
                                           detail.values,
                                           'values')
Пример #11
0
    def test_attributes(self):
        # ARRANGE #
        a_detail = sut.StringDetail('the string')
        indented = [a_detail]
        detail = sut.IndentedDetail(indented)

        # ACT & ASSERT #

        self.assertIs(indented,
                      detail.details,
                      'details')

        expected_values = asrt.matches_singleton_sequence(asrt.is_(a_detail))

        expected_values.apply_with_message(self,
                                           detail.details,
                                           'details')
Пример #12
0
    def __init__(self,
                 name: str,
                 result: bool,
                 ):
        super().__init__(result)
        self._name = name

        self._trace_tree = tree.Node(name,
                                     result,
                                     (tree.StringDetail(logic.BOOLEANS[result]),),
                                     ())
        self._matching_result = MatchingResult(
            result,
            renderers.Constant(
                self._trace_tree
            ),
        )
Пример #13
0
def _render_string(x: ToStringObject) -> Detail:
    return tree.StringDetail(x)
Пример #14
0
 def render(self) -> Sequence[Detail]:
     return [tree.StringDetail(self._to_string_object)]
Пример #15
0
 def render(self) -> Sequence[Detail]:
     sr = repr(self._value) + HAS_MORE_DATA_MARKER
     return [tree.StringDetail(sr)]
Пример #16
0
 def render(self) -> Sequence[Detail]:
     return [
         tree.StringDetail(renderer.render())
         for renderer in self._renderer.renders()
     ]
Пример #17
0
 def render(self) -> Sequence[Detail]:
     return [
         tree.StringDetail(self._path.value.render()),
         tree.StringDetail(self._path.primitive.render()),
     ]