def _apply( self, put: unittest.TestCase, value: FileMatcher, message_builder: MessageBuilder, ): actual = value.matches_w_trace(self.MODEL) asrt_matching_result.matches_value(self.expected).apply( put, actual, message_builder.for_sub_component('application result'))
def runTest(self): lines = ['1', '2', '3'] actual_number_of_lines = len(lines) integer_matcher = IntegerMatcherSymbolContext.of_primitive( 'INTEGER_MATCHER', matchers.matcher( comparators.EQ, actual_number_of_lines, )) integration_check.CHECKER__PARSE_SIMPLE.check( self, args.NumLines( integer_matcher.name__sym_ref_syntax).as_remaining_source, model_constructor.of_str(self, lines_content(lines)), arrangement_w_tcds(symbols=integer_matcher.symbol_table, ), Expectation( ParseExpectation( source=asrt_source.is_at_end_of_line(1), symbol_references=integer_matcher.references_assertion, ), ExecutionExpectation( main_result=asrt_matching_result.matches_value(True)), ), )
def runTest(self): # ARRANGE # model = model_constructor.of_str(self, 'string with at least one line') line_matcher = LineMatcherSymbolContextOfPrimitiveConstant( 'MATCHER', True, ) after_bin_op = 'after bin op' lm_argument = lm_args.And([ lm_args.SymbolReference(line_matcher.name), lm_args.Custom(after_bin_op), ]) for quantifier in Quantifier: arguments = args2.Quantification(quantifier, lm_argument.as_str) with self.subTest(quantifier): # ACT & ASSERT # integration_check.CHECKER__PARSE_SIMPLE.check( self, source=arguments.as_remaining_source, input_=model, arrangement=arrangement_w_tcds( symbols=line_matcher.symbol_table, ), expectation=Expectation( ParseExpectation(source=asrt_source.is_at_line( current_line_number=1, remaining_part_of_current_line=lm_argument. operator_name + ' ' + after_bin_op), symbol_references=line_matcher. references_assertion), ExecutionExpectation( main_result=asrt_matching_result.matches_value( line_matcher.result_value))), )
def test_stdin_contains_model_contents_WHEN_program_do_not_define_stdin( self): # ARRANGE # test_setup = SingleStdinOfProgramTestSetup(self, exit_code=0) for pgm_and_args_case in pgm_and_args_cases.cases_w_and_wo_argument_list__including_program_reference( ): with self.subTest(pgm_and_args_case.name): # ACT & ASSERT # integration_check.CHECKER__PARSE_FULL.check__abs_stx( self, abstract_syntaxes.RunProgramAbsStx( pgm_and_args_case.pgm_and_args, ), model_constructor.of_str( self, test_setup.STRING_SOURCE_CONTENTS), arrangement_w_tcds( symbols=pgm_and_args_case.symbol_table, process_execution=test_setup. proc_exe_env__w_stdin_check, tcds_contents=pgm_and_args_case.tcds, ), Expectation( ParseExpectation(symbol_references=pgm_and_args_case. references_assertion, ), execution=ExecutionExpectation( main_result=asrt_matching_result.matches_value( True)), ))
def _check(self, expected_contents: str, actual_contents: str, may_depend_on_external_resources: bool, expected_result: bool, ): string_source_symbol_with_expected = StringSourceSymbolContext.of_primitive_constant( 'EXPECTED_CONTENTS_SYMBOL', expected_contents, ) integration_check.CHECKER__PARSE_SIMPLE.check( self, args2.Equals.eq_string( string_source_symbol_with_expected.name__sym_ref_syntax ).as_remaining_source, model_constructor.of_str( self, actual_contents, may_depend_on_external_resources=may_depend_on_external_resources, ), arrangement_w_tcds( symbols=string_source_symbol_with_expected.symbol_table ), Expectation( ParseExpectation( symbol_references=string_source_symbol_with_expected.references_assertion, ), execution=ExecutionExpectation( main_result=asrt_matching_result.matches_value( expected_result ) ), ), )
def runTest(self): expected_contents = 'expected-contents' resolving_env = PathResolvingEnvironmentPreOrPostSds(fake_tcds()) sdv = self._sdv_expecting_equals(expected_contents) adv = sdv.resolve(resolving_env.symbols).value_of_any_dependency(resolving_env.tcds) for actual_contents in [expected_contents, expected_contents + '-unexpected']: expected_result = actual_contents == expected_contents expected_matching_result = asrt_matching_result.matches_value(expected_result) with self.subTest(expected_result=expected_result): model_w_ext_deps = model_constructor.of_str( self, actual_contents, may_depend_on_external_resources=True, ) with tmp_dir() as dir_space_dir__matcher: matcher = adv.primitive(self._app_env(dir_space_dir__matcher, 'matcher-path')) with tmp_dir() as dir_space_dir__model: model = model_w_ext_deps(FullResolvingEnvironment( resolving_env.symbols, resolving_env.tcds, self._app_env(dir_space_dir__model, 'model-path') )) # ACT # matching_result_1st = matcher.matches_w_trace(model) matching_result_2nd = matcher.matches_w_trace(model) # ASSERT # expected_matching_result.apply_with_message(self, matching_result_1st, '1st') expected_matching_result.apply_with_message(self, matching_result_2nd, '2nd')
def test_transformation_SHOULD_apply_only_to_matcher_argument(self): to_upper_transformer = StringTransformerSymbolContext.of_primitive( 'the_to_upper_transformer', string_transformers.to_uppercase()) model = contents_transformation.TransformedContentsSetup( original='text', transformed='TEXT', ) integration_check.CHECKER__PARSE_FULL.check__w_source_variants( self, args2.conjunction([ args2.Parentheses( args2.Transformed( to_upper_transformer.name, args2.Equals.eq_string(model.transformed)), ), args2.Equals.eq_string(model.original), ]).as_arguments, model_constructor.of_str(self, model.original), arrangement_w_tcds(symbols=to_upper_transformer.symbol_table), Expectation( ParseExpectation( symbol_references=asrt.matches_singleton_sequence( is_reference_to_string_transformer( to_upper_transformer.name))), ExecutionExpectation( main_result=asrt_matching_result.matches_value(True))))
def test_stdin_is_contents_of_string_source_WHEN_program_defines_single_stdin(self): # ARRANGE # test_setup = SingleStdinOfProgramTestSetup(self, exit_code=0) for pgm_and_args_case in pgm_and_args_cases.cases_w_and_wo_argument_list__including_program_reference(): with self.subTest(pgm_and_args_case.name): # ACT & ASSERT # integration_check.CHECKER__PARSE_FULL.check__abs_stx__layouts__source_variants( self, equivalent_source_variants__for_expr_parse__s__nsc, abstract_syntaxes.RunProgramAbsStx( test_setup.program_w_stdin_syntax(pgm_and_args_case.pgm_and_args), abstract_syntaxes.PathArgumentPositionLast() ), integration_check.ARBITRARY_MODEL, arrangement_w_tcds( symbols=pgm_and_args_case.symbol_table, process_execution=test_setup.proc_exe_env__w_stdin_check, tcds_contents=pgm_and_args_case.tcds, ), MultiSourceExpectation( symbol_references=pgm_and_args_case.references_assertion, execution=ExecutionExpectation( main_result=asrt_matching_result.matches_value(True) ), ), )
def test_stdin_is_devnull_WHEN_program_do_not_define_stdin(self): # ARRANGE # test_setup = NoStdinTestSetup(self, exit_code=0) for pgm_and_args_case in pgm_and_args_cases.cases_w_and_wo_argument_list__including_program_reference(): with self.subTest(pgm_and_args_case.name): # ACT & ASSERT # integration_check.CHECKER__PARSE_FULL.check__abs_stx( self, abstract_syntaxes.RunProgramAbsStx( pgm_and_args_case.pgm_and_args, abstract_syntaxes.PathArgumentPositionLast() ), integration_check.ARBITRARY_MODEL, arrangement_w_tcds( symbols=pgm_and_args_case.symbol_table, process_execution=test_setup.proc_exe_env__w_stdin_check, tcds_contents=pgm_and_args_case.tcds, ), Expectation( ParseExpectation( symbol_references=pgm_and_args_case.references_assertion, ), execution=ExecutionExpectation( main_result=asrt_matching_result.matches_value(True) ), ) )
def test_integer_transformer_should_be_parsed_as_simple_expression(self): # ARRANGE # after_lhs_expression = logic.AND_OPERATOR_NAME + ' after bin op' matcher_symbol = IntegerMatcherSymbolContextOfPrimitiveConstant( 'MATCHER_SYMBOL', True, ) complex_expression = ' '.join( (matcher_symbol.name__sym_ref_syntax, after_lhs_expression)) # ACT & ASSERT # integration_check.CHECKER__PARSE_SIMPLE.check( self, args.NumFiles(complex_expression, ).as_remaining_source, model.arbitrary_model(), arrangement_w_tcds(symbols=matcher_symbol.symbol_table, ), Expectation( ParseExpectation( source=asrt_source.is_at_line( current_line_number=1, remaining_part_of_current_line=after_lhs_expression, ), symbol_references=matcher_symbol.references_assertion, ), ExecutionExpectation( main_result=asrt_matching_result.matches_value( matcher_symbol.result_value)), ))
def runTest(self): checked_file = File.empty('checked-file.txt') string_matcher = StringMatcherSymbolContextOfPrimitiveConstant( 'STRING_MATCHER', True, ) after_bin_op = 'after bin op' integration_check.CHECKER__PARSE_SIMPLE.check( self, source=fm_args.FileContents( sm_args2.conjunction([ sm_args2.SymbolReference(string_matcher.name), sm_args2.Custom(after_bin_op), ]), ).as_remaining_source, input_=integration_check.constant_relative_file_name( checked_file.name), arrangement=arrangement_w_tcds( symbols=string_matcher.symbol_table, tcds_contents=tcds_populators.in_tc_dir( RelOptionType.REL_ACT, DirContents([checked_file]))), 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( string_matcher.result_value))), )
def runTest(self): # ARRANGE # files_matcher_name = 'the_files_matcher' checked_dir_location = RelSdsOptionType.REL_TMP checked_dir = Dir.empty('checked-dir') # ACT & ASSERT # integration_check.CHECKER__PARSE_FULL.check_multi__w_source_variants( self, arguments=args.DirContents( fsm_args.SymbolReference(files_matcher_name)).as_arguments, input_=integration_check.file_in_sds(checked_dir_location, checked_dir.name), symbol_references=asrt.matches_singleton_sequence( is_reference_to_files_matcher(files_matcher_name)), execution=[ NExArr( 'checked dir is empty', PrimAndExeExpectation.of_exe( main_result=asrt_matching_result.matches_value( matcher_result)), arrangement_w_tcds( non_hds_contents=sds_populator.contents_in( checked_dir_location, DirContents([checked_dir])), symbols=FilesMatcherSymbolContext. of_primitive_constant(files_matcher_name, matcher_result).symbol_table, ), ) for matcher_result in [False, True] ], )
def runTest(self): # ARRANGE # files_matcher = FilesMatcherSymbolContextOfPrimitiveConstant( 'MATCHER', True, ) after_bin_op = 'after bin op' # ACT & ASSERT # fsm_argument = fsm_args.conjunction([ fsm_args.SymbolReference(files_matcher.name), fsm_args.Custom(after_bin_op), ]) integration_check.CHECKER__PARSE_SIMPLE.check( self, source=args.DirContents(fsm_argument, ).as_remaining_source, input_=integration_check.current_directory(), arrangement=arrangement_w_tcds( symbols=files_matcher.symbol_table, ), expectation=Expectation( ParseExpectation( source=asrt_source.is_at_line( current_line_number=1, remaining_part_of_current_line=fsm_argument.operator + ' ' + after_bin_op), symbol_references=files_matcher.references_assertion), ExecutionExpectation( main_result=asrt_matching_result.matches_value( files_matcher.result_value))), )
def test_stdin_is_concatenation_of_model_and_program_stdin_WHEN_program_defines_single_stdin( self): # ARRANGE # model_contents = '\n'.join(('the', 'contents', 'of', 'the', 'model')) test_setup = SingleStdinOfProgramTestSetup( self, exit_code=0, additional_stdin=model_contents) for pgm_and_args_case in pgm_and_args_cases.cases_w_and_wo_argument_list__including_program_reference( ): with self.subTest(pgm_and_args_case.name): # ACT & ASSERT # integration_check.CHECKER__PARSE_FULL.check__abs_stx__layouts__source_variants( self, equivalent_source_variants__for_expr_parse__s__nsc, abstract_syntaxes.RunProgramAbsStx( test_setup.program_w_stdin_syntax( pgm_and_args_case.pgm_and_args), ), model_constructor.of_str(self, model_contents), arrangement_w_tcds( symbols=pgm_and_args_case.symbol_table, process_execution=test_setup. proc_exe_env__w_stdin_check, tcds_contents=pgm_and_args_case.tcds, ), MultiSourceExpectation( symbol_references=pgm_and_args_case. references_assertion, execution=ExecutionExpectation( main_result=asrt_matching_result.matches_value( True)), ), )
def _check(self, expected_contents: str, actual_contents: str, may_depend_on_external_resources: bool, expected_result: bool, ): expected_file_relativity = rel_opt.conf_rel_any(RelOptionType.REL_HDS_CASE) expected_contents_file = File('expected.txt', expected_contents) integration_check.CHECKER__PARSE_SIMPLE.check( self, args2.Equals.eq_file( expected_file_relativity.path_argument_of_rel_name(expected_contents_file.name) ).as_remaining_source, model_constructor.of_str(self, actual_contents, may_depend_on_external_resources=may_depend_on_external_resources), arrangement_w_tcds( tcds_contents=expected_file_relativity.populator_for_relativity_option_root( DirContents([expected_contents_file]) ) ), Expectation( execution=ExecutionExpectation( main_result=asrt_matching_result.matches_value( expected_result ) ), ), )
def runTest(self): after_lhs_expression = logic.AND_OPERATOR_NAME + ' after bin op' integer_matcher = IntegerMatcherSymbolContextOfPrimitiveConstant( 'MATCHER_SYMBOL', True, ) complex_expression = ' '.join( (integer_matcher.name__sym_ref_syntax, after_lhs_expression)) integration_check.CHECKER__PARSE_SIMPLE.check( self, args.NumLines(complex_expression).as_remaining_source, model_constructor.arbitrary(self), arrangement_w_tcds(symbols=integer_matcher.symbol_table, ), Expectation( ParseExpectation( source=asrt_source.is_at_line( current_line_number=1, remaining_part_of_current_line=after_lhs_expression, ), symbol_references=integer_matcher.references_assertion, ), ExecutionExpectation( main_result=asrt_matching_result.matches_value( integer_matcher.result_value)), ), )
def test_tree_of_transformations(self): # ARRANGE # to_upper_transformer = StringTransformerSymbolContext.of_primitive( 'the_to_upper_transformer', string_transformers.to_uppercase()) keep_line_1 = StringTransformerSymbolContext.of_primitive( 'keep_line_1', string_transformers.keep_single_line(1)) keep_line_2 = StringTransformerSymbolContext.of_primitive( 'keep_line_2', string_transformers.keep_single_line(2)) equals_1st = StringMatcherSymbolContext.of_primitive( 'equals_1st', string_matchers.EqualsConstant('1ST\n')) equals_2nd = StringMatcherSymbolContext.of_primitive( 'equals_2nd', string_matchers.EqualsConstant('2ND\n')) model__original = '1st\n2nd\n' symbol_contexts = [ to_upper_transformer, keep_line_1, equals_1st, keep_line_2, equals_2nd, ] # ACT & ASSERT # integration_check.CHECKER__PARSE_FULL.check__w_source_variants( self, args2.Transformed( to_upper_transformer.name__sym_ref_syntax, args2.Parentheses( args2.conjunction([ args2.Parentheses( args2.Transformed( keep_line_1.name__sym_ref_syntax, args2.SymbolReference(equals_1st.name), )), args2.Parentheses( args2.Transformed( keep_line_2.name__sym_ref_syntax, args2.SymbolReference(equals_2nd.name), )), ]))).as_arguments, model_constructor.of_str(self, model__original), arrangement_w_tcds(symbols=SymbolContext.symbol_table_of_contexts( symbol_contexts)), Expectation( ParseExpectation( symbol_references=SymbolContext. references_assertion_of_contexts(symbol_contexts)), ExecutionExpectation( main_result=asrt_matching_result.matches_value(True))))
def _execution_expectation_of( expected: ExecutionResult) -> ExecutionExpectation: if isinstance(expected, FullExecutionResult): return ExecutionExpectation( main_result=asrt_matching_result.matches_value(expected.is_match)) elif isinstance(expected, ValidationFailure): return ExecutionExpectation(validation=validation.ValidationAssertions. of_expectation(expected.expectation)) raise ValueError('Unknown {}: {}'.format( str(type(ExecutionResult)), expected, ))
def runTest(self): # ARRANGE # model_contents = '\n'.join(('the', 'contents', 'of', 'the', 'model')) test_setup = StdinCheckWithProgramWExitCode0ForSuccess() # ACT & ASSERT # integration_check.CHECKER__PARSE_FULL.check__abs_stx( self, abstract_syntaxes.RunProgramAbsStx( test_setup.program_that_checks_stdin__syntax( 'the contents of stdin', model_contents), ), model_constructor.of_str(self, model_contents), arrangement_w_tcds(tcds_contents=test_setup.tcds_contents, ), Expectation(execution=ExecutionExpectation( main_result=asrt_matching_result.matches_value(True)), ), )
def runTest(self): # ARRANGE # checked_dir_rel_conf = relativity_options.conf_rel_any(RelOptionType.REL_ACT) checked_dir_populator = checked_dir_rel_conf.populator_for_relativity_option_root( DirContents([ File.empty('a-file-so-that-checked-dir-is-not-empty') ] ) ) file_matcher = FileMatcherSymbolContextOfPrimitiveConstant( 'MATCHER', True, ) after_bin_op = 'after bin op' fm_argument = fm_args.conjunction([ fm_args.SymbolReference(file_matcher.name), fm_args.Custom(after_bin_op), ]) # ACT & ASSERT # for quantifier in Quantifier: arguments = args.Quantification(quantifier, fm_argument) with self.subTest(quantifier): # ACT & ASSERT # integration_check.CHECKER__PARSE_SIMPLE.check( self, source=arguments.as_remaining_source, input_=model.model_constructor__non_recursive( path_sdvs.of_rel_option(checked_dir_rel_conf.relativity) ), arrangement=arrangement_w_tcds( symbols=file_matcher.symbol_table, tcds_contents=checked_dir_populator ), expectation=Expectation( ParseExpectation( source=asrt_source.is_at_line( current_line_number=1, remaining_part_of_current_line=fm_argument.operator + ' ' + after_bin_op), symbol_references=file_matcher.references_assertion ), ExecutionExpectation( main_result=asrt_matching_result.matches_value(file_matcher.result_value) ) ), )
def _check(self, file_type_to_check_for: FileType, expected_result: bool, base_name_of_file_to_check: str, dir_contents: DirContents): # ACT # integration_check.CHECKER__PARSE_FULL.check__w_source_variants( self, ArgumentElements(arg.Type(file_type_to_check_for).elements).as_arguments, integration_check.constant_relative_file_name(base_name_of_file_to_check), arrangement_w_tcds( non_hds_contents=non_hds_populator.rel_option(RelNonHdsOptionType.REL_CWD, dir_contents), ), Expectation( execution=ExecutionExpectation( main_result=asrt_matching_result.matches_value(expected_result), ), ) )
def runTest(self): # ARRANGE # test_setup = StdinCheckWithProgramWExitCode0ForSuccess() # ACT & ASSERT # integration_check.CHECKER__PARSE_FULL.check__abs_stx( self, abstract_syntaxes.RunProgramAbsStx( test_setup.program_that_checks_stdin__syntax('the contents of stdin'), abstract_syntaxes.PathArgumentPositionLast() ), integration_check.ARBITRARY_MODEL, arrangement_w_tcds( tcds_contents=test_setup.tcds_contents, ), Expectation( execution=ExecutionExpectation( main_result=asrt_matching_result.matches_value(True) ), ), )
def test_integer_matcher_on_new_line(self): # ARRANGE # checked_dir_contents = DirContents([File.empty('1'), File.empty('2')]) checked_path = rel_opts.conf_rel_sds(RelSdsOptionType.REL_ACT) # ACT & ASSERT # integration_check.CHECKER__PARSE_SIMPLE.check( self, args.NumFiles( int_condition(comparators.EQ, len(checked_dir_contents.file_system_elements)), int_expr_on_new_line=True, ).as_remaining_source, model.model_with_rel_root_as_source_path(checked_path), arrangement_w_tcds( tcds_contents=checked_path. populator_for_relativity_option_root(checked_dir_contents), ), Expectation( ParseExpectation(source=asrt_source.is_at_end_of_line(2)), ExecutionExpectation( main_result=asrt_matching_result.matches_value(True)), ))
def runTest(self): any_char_regex_string_symbol = StringSymbolContext.of_constant( 'valid_regex_string_symbol', '.', ) arguments = name_matches_regex_args( 'AB' + any_char_regex_string_symbol.name__sym_ref_syntax) self._check_with_source_variants( arguments=arguments, model_constructor=integration_check.constant_relative_file_name( 'ABC'), arrangement=arrangement_w_tcds( symbols=any_char_regex_string_symbol.symbol_table), expectation=Expectation( ParseExpectation(symbol_references=asrt.matches_sequence([ is_reference_to__regex_string_part( any_char_regex_string_symbol.name), ]), ), ExecutionExpectation( main_result=asrt_matching_result.matches_value(True)), ))
def runTest(self): any_char_glob_pattern_string_symbol = StringSymbolContext.of_constant( 'glob_pattern_string_symbol', '*') arguments = arg.Name( arg.NameGlobPatternVariant( 'AB' + any_char_glob_pattern_string_symbol.name__sym_ref_syntax)) integration_check.CHECKER__PARSE_FULL.check__w_source_variants( self, arguments=arguments.as_arguments, input_=integration_check.constant_relative_file_name('ABC'), arrangement=arrangement_w_tcds( symbols=any_char_glob_pattern_string_symbol.symbol_table), expectation=Expectation( ParseExpectation(symbol_references=asrt.matches_sequence([ is_reference_to__regex_string_part( any_char_glob_pattern_string_symbol.name), ]), ), ExecutionExpectation( main_result=asrt_matching_result.matches_value(True)), ))
def test_stdin_is_concatenation_of_string_sources_WHEN_program_defines_multiple_stdin(self): # ARRANGE # test_setup = MultipleStdinOfProgramTestSetup(self, exit_code=0) # ACT & ASSERT # integration_check.CHECKER__PARSE_FULL.check__abs_stx__layouts__source_variants( self, equivalent_source_variants__for_expr_parse__s__nsc, abstract_syntaxes.RunProgramAbsStx( test_setup.program_w_stdin_syntax, abstract_syntaxes.PathArgumentPositionLast() ), integration_check.ARBITRARY_MODEL, arrangement_w_tcds( symbols=test_setup.program_symbol.symbol_table, process_execution=test_setup.proc_exe_env__w_stdin_check, ), MultiSourceExpectation( symbol_references=test_setup.program_symbol.references_assertion, execution=ExecutionExpectation( main_result=asrt_matching_result.matches_value(True) ), ), )
def runTest(self): model__original = 'the model text' the_model_constructor = model_constructor.of_str(self, model__original) string_transformer = StringTransformerSymbolContext.of_primitive( 'THE_STRING_TRANSFORMER', string_transformers.to_uppercase()) sm_equals = StringMatcherSymbolContext.of_primitive( 'STRING_MATCHER_1', string_matchers.EqualsConstant(model__original.upper())) symbol = [ string_transformer, sm_equals, ] after_bin_op = 'after bin op' sm_conjunction = args2.conjunction([ args2.SymbolReference(sm_equals.name), args2.Custom(after_bin_op), ]) arguments = args2.Transformed(string_transformer.name__sym_ref_syntax, sm_conjunction) integration_check.CHECKER__PARSE_SIMPLE.check( self, source=arguments.as_remaining_source, input_=the_model_constructor, arrangement=arrangement_w_tcds( symbols=SymbolContext.symbol_table_of_contexts(symbol), ), expectation=Expectation( ParseExpectation(source=asrt_source.is_at_line( current_line_number=1, remaining_part_of_current_line=' '.join( [sm_conjunction.operator, after_bin_op])), symbol_references=SymbolContext. references_assertion_of_contexts(symbol)), ExecutionExpectation( main_result=asrt_matching_result.matches_value(True))), )
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, )
def test_matcher_symbol_should_be_reported(self): # ARRANGE # matcher_symbol = IntegerMatcherSymbolContextOfPrimitiveConstant( 'MATCHER_SYMBOL', True, ) # ACT & ASSERT # integration_check.CHECKER__PARSE_SIMPLE.check( self, args.NumFiles( matcher_symbol.name__sym_ref_syntax, int_expr_on_new_line=True, ).as_remaining_source, model.arbitrary_model(), arrangement_w_tcds(symbols=matcher_symbol.symbol_table, ), Expectation( ParseExpectation( source=asrt_source.is_at_end_of_line(2), symbol_references=matcher_symbol.references_assertion, ), ExecutionExpectation( main_result=asrt_matching_result.matches_value( matcher_symbol.result_value)), ))
def test_symbols_from_comparison_SHOULD_be_reported(self): # ARRANGE # checked_dir_contents = DirContents([File.empty('1'), File.empty('2')]) checked_path = rel_opts.conf_rel_sds(RelSdsOptionType.REL_ACT) operand_sym_ref = StringIntConstantSymbolContext( 'operand_symbol_name', len(checked_dir_contents.file_system_elements), default_restrictions=symbol_reference. is_reference_restrictions__integer_expression(), ) matcher_arguments = im_args.comparison(comparators.EQ, operand_sym_ref.argument) # ACT & ASSERT # integration_check.CHECKER__PARSE_SIMPLE.check( self, args.NumFiles( matcher_arguments.as_str, int_expr_on_new_line=True, ).as_remaining_source, model.model_with_rel_root_as_source_path(checked_path), arrangement_w_tcds( symbols=operand_sym_ref.symbol_table, tcds_contents=checked_path. populator_for_relativity_option_root(checked_dir_contents), ), Expectation( ParseExpectation( source=asrt_source.is_at_end_of_line(2), symbol_references=operand_sym_ref.references_assertion, ), ExecutionExpectation( main_result=asrt_matching_result.matches_value(True)), ))