コード例 #1
0
ファイル: line_matchers.py プロジェクト: emilkarlen/exactly
def successful_matcher_with_validation(
        validator: DdvValidator) -> LineMatcherSdv:
    return sdv_ddv.sdv_from_primitive_value(
        constant.MatcherWithConstantResult(True),
        (),
        validator,
    )
コード例 #2
0
ファイル: symbol_context.py プロジェクト: emilkarlen/exactly
 def of_primitive(
     primitive: IntegerMatcher,
     definition_source: Optional[
         SourceLocationInfo] = ARBITRARY_LINE_SEQUENCE_FOR_DEFINITION,
 ) -> 'IntegerMatcherSymbolValueContext':
     return IntegerMatcherSymbolValueContext.of_sdv(
         sdv_ddv.sdv_from_primitive_value(primitive), definition_source)
コード例 #3
0
 def test_expect_match_is_true(self):
     self._check_raises_test_error__single_and_multi(
         _constant_line_matcher_type_parser_of_matcher_sdv(
             sdv_ddv.sdv_from_primitive_value(constant.MatcherWithConstantResult(False))
         ),
         is_expectation_of_execution_result_of(True),
     )
コード例 #4
0
 def test_expects_no_hard_error(self):
     parser_that_gives_value_that_causes_hard_error = _constant_line_matcher_type_parser_of_matcher_sdv(
         sdv_ddv.sdv_from_primitive_value(MatcherThatReportsHardError())
     )
     self._check_raises_test_error__single_and_multi(
         parser_that_gives_value_that_causes_hard_error,
         is_expectation_of_execution_result_of(True),
     )
コード例 #5
0
 def test_expect_no_symbol_usages(self):
     self._check_raises_test_error__single_and_multi(
         _constant_line_matcher_type_parser_of_matcher_sdv(
             sdv_ddv.sdv_from_primitive_value(
                 references=[
                     data_references.reference_to__on_direct_and_indirect('symbol_name')])
         ),
         is_expectation_of_execution_result_of(True),
     )
コード例 #6
0
ファイル: line_matchers.py プロジェクト: emilkarlen/exactly
def sdv_from_primitive_value(
    primitive_value: MatcherWTrace[LineMatcherLine] = constant.
    MatcherWithConstantResult(True),
    references: Sequence[SymbolReference] = (),
    validator: DdvValidator = ConstantDdvValidator.new_success(),
) -> LineMatcherSdv:
    return sdv_ddv.sdv_from_primitive_value(
        primitive_value,
        references,
        validator,
    )
コード例 #7
0
 def __init__(self,
              symbol_name: str,
              actual: ValidationActual,
              ):
     self.actual = actual
     self._symbol_context = IntegerMatcherSymbolContext.of_sdv(
         symbol_name,
         sdv_ddv.sdv_from_primitive_value(
             validator=DdvValidatorThat.corresponding_to(actual)
         )
     )
コード例 #8
0
    def test_that_fails_due_to_missing_symbol_reference(self):
        symbol_usages_of_matcher = []
        symbol_usages_of_expectation = [
            data_references.reference_to__on_direct_and_indirect('symbol_name')]

        self._check_raises_test_error__single_and_multi(
            _constant_line_matcher_type_parser_of_matcher_sdv(
                sdv_ddv.sdv_from_primitive_value(references=symbol_usages_of_matcher)
            ),
            Expectation(
                ParseExpectation(
                    symbol_references=sym_asrt.equals_symbol_references__w_str_rendering(
                        symbol_usages_of_expectation)
                ),
            )
        )
コード例 #9
0
    def test_fail_due_to_unsatisfied_assertion_on_output_from_application(self):
        matcher_result_value = True
        for check_application_result_with_tcds in [False, True]:
            parser = _constant_line_matcher_type_parser_of_matcher_sdv(
                sdv_ddv.sdv_from_primitive_value(constant.MatcherWithConstantResult(matcher_result_value))
            )
            checker = sut.IntegrationChecker(
                parser,
                _CustomMatcherPropertiesConfiguration(asrt_matching_result.matches_value(not matcher_result_value)),
                check_application_result_with_tcds,
            )

            expectation = is_expectation_of_execution_result_of(matcher_result_value)
            for arrangement in _EMPTY_ARRANGEMENT_W_WO_TCDS:
                with self.subTest(arrangement.name,
                                  check_application_result_with_tcds=check_application_result_with_tcds,
                                  execution_variant='single execution'):
                    with self.assertRaises(utils.TestError):
                        self._check(
                            utils.single_line_source(),
                            ARBITRARY_MODEL,
                            checker,
                            arrangement.value,
                            expectation,
                        )

                with self.subTest(arrangement.name,
                                  check_application_result_with_tcds=check_application_result_with_tcds,
                                  execution_variant='multiple execution'):
                    with self.assertRaises(utils.TestError):
                        self._check___multi(
                            utils.single_line_arguments(),
                            ARBITRARY_MODEL,
                            checker,
                            arrangement.value,
                            expectation,
                        )
コード例 #10
0
def _constant_line_matcher_type_parser_of_matcher(matcher: MatcherWTrace[int]
                                                  ) -> Parser[MatcherSdv[int]]:
    return _ConstantParserOfSingleTokenExpression(
        sdv_ddv.sdv_from_primitive_value(matcher))
コード例 #11
0
    return _ConstantParserOfSingleTokenExpression(
        sdv_ddv.MatcherSdvOfConstantDdvTestImpl(matcher))


def _constant_line_matcher_type_parser_of_matcher(matcher: MatcherWTrace[int]
                                                  ) -> Parser[MatcherSdv[int]]:
    return _ConstantParserOfSingleTokenExpression(
        sdv_ddv.sdv_from_primitive_value(matcher))


ARBITRARY_MODEL = 0
ARBITRARY_MODEL_CONSTRUCTOR = constant_model(ARBITRARY_MODEL)

PARSER_THAT_GIVES_MATCHER_THAT_MATCHES_WO_SYMBOL_REFS_AND_SUCCESSFUL_VALIDATION = \
    _constant_line_matcher_type_parser_of_matcher_sdv(
        sdv_ddv.sdv_from_primitive_value()
    )

_MATCHER_THAT_MATCHES = sdv_ddv.sdv_from_primitive_value()


def dir_is_empty(tcds_dir: RelOptionType) -> Assertion[TestCaseDs]:
    return asrt.sub_component(str(tcds_dir),
                              REL_OPTIONS_MAP[tcds_dir].root_resolver.from_tcds,
                              file_assertions.dir_is_empty())


def parser_of_matcher_that_is_an_assertion_on_tcds(put: unittest.TestCase,
                                                   assertion: Assertion[TestCaseDs],
                                                   ) -> Parser[MatcherSdv[int]]:
    return _constant_line_matcher_type_parser_of_matcher_ddv(