コード例 #1
0
    def test_glob_pattern(self):
        match_anything_glob_pattern_string_symbol = StringSymbolContext.of_constant(
            'glob_pattern_symbol',
            '*',
            default_restrictions=glob_pattern.is_reference_restrictions__glob_pattern_string()
        )
        arguments = self.conf.arguments(
            NameGlobPatternVariant(match_anything_glob_pattern_string_symbol.name__sym_ref_syntax)
        )

        integration_check.CHECKER__PARSE_SIMPLE.check__w_source_variants(
            self,
            arguments=
            arguments.as_arguments,
            input_=
            ARBITRARY_MODEL,
            arrangement=arrangement_wo_tcds(
                symbols=match_anything_glob_pattern_string_symbol.symbol_table
            ),
            expectation=Expectation(
                ParseExpectation(
                    symbol_references=asrt.matches_sequence([
                        match_anything_glob_pattern_string_symbol.reference_assertion,
                    ]),
                ),
                ExecutionExpectation(
                    main_result=asrt_matching_result.matches_value__w_header(
                        asrt.equals(True),
                        asrt.equals(self.conf.node_name)
                    )
                ),
            )
        )
コード例 #2
0
 def runTest(self):
     string_matcher = StringMatcherSymbolContextOfPrimitiveConstant(
         'STRING_MATCHER',
         True,
     )
     after_bin_op = 'after bin op'
     integration_check.CHECKER__PARSE_SIMPLE.check(
         self,
         source=lm_args.Contents(
             sm_args2.conjunction([
                 sm_args2.SymbolReference(string_matcher.name),
                 sm_args2.Custom(after_bin_op),
             ]), ).as_remaining_source,
         input_=models.ARBITRARY_MODEL,
         arrangement=arrangement_wo_tcds(
             symbols=string_matcher.symbol_table, ),
         expectation=Expectation(
             ParseExpectation(
                 source=asrt_source.is_at_line(
                     current_line_number=1,
                     remaining_part_of_current_line=logic.AND_OPERATOR_NAME
                     + ' ' + after_bin_op),
                 symbol_references=string_matcher.references_assertion),
             ExecutionExpectation(
                 main_result=asrt_matching_result.matches_value__w_header(
                     asrt.equals(string_matcher.result_value),
                     header=TRACE_HEADER_EXPECTATION,
                 ))),
     )
コード例 #3
0
def is_result_for_py_interpreter(exit_code: int) -> Assertion[MatchingResult]:
    return asrt_matching_result.matches_value__w_header(
        value=asrt.equals(exit_code == 0),
        header=asrt.equals(_EXPECTED_HEADER),
        details=asrt.is_sequence_with_element_at_pos(
            0,
            asrt_pgm_trace.matches_pgm_as_detail__py_interpreter()
        )
    )
コード例 #4
0
ファイル: files_condition.py プロジェクト: emilkarlen/exactly
def exe_w_added_header_matcher(matcher_header: str,
                               original: ExecutionExpectation[bool],
                               ) -> ExecutionExpectation[MatchingResult]:
    return ExecutionExpectation(
        original.validation,
        asrt_matching_result.matches_value__w_header(
            value=original.main_result,
            header=asrt.equals(matcher_header)
        ),
        original.is_hard_error,
    )
コード例 #5
0
    def runTest(self):
        # ARRANGE #
        line_contents = 'the line contents'

        def get_string_matcher_model_as_single_string(
                model: StringSource) -> str:
            return model.contents().as_str

        matching_result = True
        string_matcher = StringMatcherSymbolContext.of_primitive(
            'STRING_MATCHER',
            matcher_w_init_action.matcher_that_applies_assertion(
                self,
                assertion=asrt.equals(line_contents),
                get_actual=get_string_matcher_model_as_single_string,
                message_builder=asrt.MessageBuilder.new(
                    'string-matcher-model'),
                result=matching_result,
            ),
        )
        # ACT & ASSERT #
        integration_check.CHECKER__PARSE_SIMPLE.check__w_source_variants(
            self,
            arguments=lm_args.Contents(
                sm_args2.SymbolReferenceWReferenceSyntax(
                    string_matcher.name), ).as_arguments,
            input_=models.constant((1, line_contents)),
            arrangement=arrangement_wo_tcds(
                symbols=string_matcher.symbol_table, ),
            expectation=Expectation(
                ParseExpectation(
                    symbol_references=string_matcher.references_assertion),
                ExecutionExpectation(
                    main_result=asrt_matching_result.matches_value__w_header(
                        asrt.equals(matching_result),
                        header=asrt.equals(MATCHER_NAME),
                    ))),
        )
コード例 #6
0
def check_regex(put: unittest.TestCase,
                conf: Configuration,
                pattern: str,
                ignore_case: bool,
                model: ModelConstructor,
                expected_result: bool,
                ):
    pattern_string_symbol = StringSymbolContext.of_constant(
        'PATTERN_SYMBOL',
        pattern,
        default_restrictions=is_reference_restrictions__regex()
    )
    arguments = conf.arguments(
        NameRegexVariant.of(pattern_string_symbol.name__sym_ref_syntax,
                            ignore_case=ignore_case)
    )

    integration_check.CHECKER__PARSE_SIMPLE.check__w_source_variants(
        put,
        arguments=arguments.as_arguments,
        input_=model,
        arrangement=arrangement_wo_tcds(
            symbols=pattern_string_symbol.symbol_table
        ),
        expectation=Expectation(
            ParseExpectation(
                symbol_references=asrt.matches_sequence([
                    pattern_string_symbol.reference_assertion,
                ]),
            ),
            ExecutionExpectation(
                main_result=asrt_matching_result.matches_value__w_header(
                    asrt.equals(expected_result),
                    asrt.equals(conf.node_name)
                )
            ),
        )
    )