def test_succeed(self): actual = sut.Node('expected header', None, [], []) expectation = asrt_d_tree.matches_node(header=asrt.equals('expected header')) assertion = sut.matches_node_renderer(rendered_node=expectation) assertion.apply_without_message(self, NodeRendererForTest(actual))
def test_fail(self): actual = sut.Node('actual header', None, [], []) expectation = asrt_d_tree.matches_node(header=asrt.equals('expected header')) assertion = sut.matches_node_renderer(rendered_node=expectation) assert_that_assertion_fails(assertion, NodeRendererForTest(actual))
def matches_value__w_header( value: Assertion[bool], header: Assertion[str], details: Assertion[Sequence[Detail]] = asrt.anything_goes(), children: Assertion[Sequence[Node]] = asrt.anything_goes(), ) -> Assertion[MatchingResult]: return matches(value=value, trace=asrt_trace_rendering.matches_node_renderer( asrt_d_tree.matches_node(header=header, data=value, details=details, children=children), ))
def test_succeed(self): actual_rendered_node = _trace_for(False) actual_result = MatchingResult( actual_rendered_node.data, NodeRendererForTest(actual_rendered_node)) renderer_assertion = asrt_trace_rendering.matches_node_renderer( rendered_node=asrt_d_tree.matches_node( header=asrt.equals(actual_rendered_node.header))) assertion = sut.matches(trace=renderer_assertion) assertion.apply_without_message(self, actual_result)
def test_fail(self): actual_rendered_node = Node('actual header', False, [], []) actual_result = MatchingResult( actual_rendered_node.data, NodeRendererForTest(actual_rendered_node)) renderer_assertion = asrt_trace_rendering.matches_node_renderer( rendered_node=asrt_d_tree.matches_node( header=asrt.equals('expected header'))) assertion = sut.matches(trace=renderer_assertion) assert_that_assertion_fails(assertion, actual_result)
def has_node_description() -> Assertion[FullDepsDdv[PRIMITIVE]]: return asrt.sub_component( 'description', _get_description, asrt.is_instance_with( NodeDescription, asrt.sub_component( 'structure', _get_node_description_structure, asrt_trace_rendering.matches_node_renderer(), ) ), )
def test_fail_WHEN_invalid_type(self): # ARRANGE # assertion = sut.matches_node_renderer() cases = [ NameAndValue('invalid type of node renderer', 'not a' + str(sut.NodeRenderer) ), NameAndValue('result of rendering is object of invalid type', NodeRendererForTest('not a Node') ), ] for case in cases: with self.subTest(case.name): # ACT & ASSERT # assert_that_assertion_fails(assertion, case.value)
def matches__lines__check_just_as_lines(lines: Sequence[str], structure: Assertion[NodeRenderer] = asrt_trace_rendering.matches_node_renderer(), ) -> Assertion[StringSource]: return asrt.and_([ has_structure_description(structure), contents_matches( asrt_str_src_contents.WithLinesCheck( asrt.sub_component( 'as_lines', properties_access.get_contents_from_as_lines, asrt.equals(lines), ) ), ) ])
def matches__str(contents: Assertion[str], may_depend_on_external_resources: Assertion[bool] = asrt.anything_goes(), structure: Assertion[NodeRenderer] = asrt_trace_rendering.matches_node_renderer(), ) -> Assertion[StringSource]: return asrt.and_([ has_structure_description(structure), contents_matches( asrt.and_([ asrt_str_src_contents.WithLinesCheck( asrt_str_src_contents.actual_contents_variants_assertion__str(contents) ), asrt_str_src_contents.external_dependencies(may_depend_on_external_resources), ]), ), ])
def contents_raises_hard_error(may_depend_on_external_resources: Assertion[bool], structure: Assertion[NodeRenderer] = asrt_trace_rendering.matches_node_renderer(), ) -> Assertion[StringSource]: return asrt.and_([ has_structure_description(structure), contents_matches( asrt.and_( [asrt_str_src_contents.external_dependencies(may_depend_on_external_resources)] + [ asrt.named( contents_case.name, RaisesHardErrorAsLastAction( contents_case.value ) ) for contents_case in properties_access.ALL_CASES__WO_LINES_ITER_CHECK ]), ), ])
def test_success_WHEN_actual_is_valid(self): assertion = sut.matches_node_renderer() assertion.apply_without_message(self, NodeRendererForTest(Node('header', None, [], [])))
def has_valid_structure_description() -> Assertion[StringSource]: return has_structure_description(asrt_trace_rendering.matches_node_renderer())
def trace_equals(expected: Node[bool]) -> Assertion[NodeRenderer[bool]]: return asrt_trace_rendering.matches_node_renderer(asrt_d_tree.equals_node(expected))
def visit_node(self, description: NodeDescription) -> None: assertion = asrt_trace_rendering.matches_node_renderer() assertion.apply(self._put, description.structure(), self._message_builder )
integration_check.CHECKER__PARSE_SIMPLE.check__w_source_variants( self, Arguments.of_preformatted(case.source), input_=integration_check.constant(model_info.model), arrangement=arrangement_wo_tcds( symbols=case.symbols, ), expectation=Expectation( ParseExpectation( symbol_references=case.references, ), ExecutionExpectation( main_result=asrt_matching_result.matches( value=asrt.equals(expected_result.value), trace=asrt_trace_rendering.matches_node_renderer( asrt_d_tree.equals_node(expected_result.trace.render()), ) ) ), prim_asrt__constant( asrt_w_interval.is_with_interval( case.interval.pos, case.interval.neg, ) ), ) ) def test_failing_validation(self): # ARRANGE # symbol_not_an_int = StringSymbolContext.of_constant('SYMBOL_NOT_AN_INT', 'notAnInt')