def test_removal_of_new_lines_SHOULD_join_lines(self): # ARRANGE # cases = [ NIE('final line not ended by new-line', input_value=[ '1\n', '2\n', '3', ], expected_value=[ '123', ]), NIE('final line ended by new-line', input_value=[ '1\n', '2\n', '3\n', ], expected_value=[ '123', ]), ] for line_filter_case in LINE_FILTER_CASES: for case in cases: with self.subTest(model=case.name, line_filtering=line_filter_case.name): nl_string_symbol = StringConstantSymbolContext( 'NL', '\n', default_restrictions=asrt_regex. is_reference_restrictions__regex(), ) all_symbols = line_filter_case.value.symbols + [ nl_string_symbol ] source = ReplaceRegexAbsStx( nl_string_symbol.abstract_syntax, StringLiteralAbsStx.empty_string(), preserve_new_lines=False, lines_filter=line_filter_case.value.syntax, ) # ACT & ASSERT # integration_check.CHECKER__PARSE_SIMPLE.check__abs_stx( self, source, model_constructor.of_lines(self, case.input_value), arrangement_w_tcds( symbols=SymbolContext.symbol_table_of_contexts( all_symbols), ), expectation_of_successful_replace_execution( symbol_references=SymbolContext. references_assertion_of_contexts(all_symbols), may_depend_on_external_resources=line_filter_case. value.may_depend_on_external_resources, output_lines=case.expected_value, ))
def execution_cases( self ) -> Sequence[NExArr[PrimAndExeExpectation[FilesMatcher, MatchingResult], Arrangement]]: return [ NExArr( case.name, PrimAndExeExpectation.of_exe(main_result=asrt_matching_result. matches_value(case.expected)), arrangement_w_tcds(non_hds_contents=sds_populator.contents_in( self.checked_dir_location, DirContents([Dir(self.checked_dir_name, case.actual)])))) for case in self.setup.cases ]
def runTest(self): unconditionally_constant_true = FilesMatcherSymbolContext.of_primitive_constant( 'unconditionally_constant_true', True) symbols = unconditionally_constant_true.symbol_table location = RelSdsOptionType.REL_TMP model_file_name = 'the-checked-file' integration_check.CHECKER__PARSE_FULL.check_multi__w_source_variants( self, arguments=args.DirContents( args.SymbolReference( unconditionally_constant_true.name)).as_arguments, symbol_references=asrt.matches_singleton_sequence( unconditionally_constant_true.reference_assertion), input_=integration_check.file_in_sds(location, model_file_name), execution=[ NExArr( invalid_file_case.name, PrimAndExeExpectation.of_exe( is_hard_error=asrt_renderer. is_renderer_of_major_blocks()), arrangement_w_tcds( symbols=symbols, non_hds_contents=sds_populator.contents_in( location, invalid_file_case.value))) for invalid_file_case in invalid_model.cases(model_file_name) ])
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 test_stdin_is_concatenation_of_string_sources_WHEN_program_defines_multiple_stdin( self): # ARRANGE # test_setup = MultipleStdinOfProgramTestSetup(self, exit_code=0) # ACT & ASSERT # for output_file in ProcOutputFile: for ignore_exit_code in [False, True]: with self.subTest(output_file=output_file, ignore_exit_code=ignore_exit_code): CHECKER.check__abs_stx__layouts__source_variants__wo_input( self, equivalent_source_variants__for_expr_parse__s__nsc, StringSourceOfProgramAbsStx( output_file, test_setup.program_w_stdin_syntax, ignore_exit_code, ), arrangement_w_tcds( symbols=test_setup.program_symbol.symbol_table, process_execution=test_setup. proc_exe_env__w_stdin_check, ), MultiSourceExpectation.of_prim__const( symbol_references=test_setup.program_symbol. references_assertion, primitive=IS_EMPTY_STRING_SOURCE, ), )
def test_stdin_is_devnull_WHEN_program_do_not_define_stdin(self): # ARRANGE # test_setup = NoStdinTestSetup(self, exit_code=0) for output_file in ProcOutputFile: for pgm_and_args_case in pgm_and_args_cases.cases_w_and_wo_argument_list__including_program_reference( ): for ignore_exit_code in [False, True]: with self.subTest(output_file=output_file, program=pgm_and_args_case.name, ignore_exit_code=ignore_exit_code): # ACT & ASSERT # CHECKER.check__abs_stx__wo_input( self, StringSourceOfProgramAbsStx( output_file, pgm_and_args_case.pgm_and_args, ignore_exit_code, ), 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.of_prim__const( parse=ParseExpectation( symbol_references=pgm_and_args_case. references_assertion, ), primitive=IS_EMPTY_STRING_SOURCE, ))
def _doTest(self, maybe_not: ExpectationTypeConfigForNoneIsSuccess): regex_lines = ['1.3', '4.*6'] here_doc_of_reg_ex = here_document_as_elements(regex_lines) actual_contents = lines_content(['123', '456', '789']) for transformer_option_arguments in TRANSFORMER_OPTION_ALTERNATIVES_ELEMENTS: with self.subTest(maybe_with_transformer_option=transformer_option_arguments): argument_elements = ArgumentElements(transformer_option_arguments + maybe_not.empty__if_positive__not_option__if_negative + [matcher_options.MATCHES_ARGUMENT, FULL_MATCH_ARGUMENT] ).followed_by(here_doc_of_reg_ex) self._check( argument_elements.as_remaining_source, model_constructor.of_str(self, actual_contents), arrangement_w_tcds(), Expectation( ParseExpectation( source=asrt_source.is_at_end_of_line(1 + len(here_doc_of_reg_ex.following_lines)) ), ExecutionExpectation( main_result=maybe_not.fail__if_positive__pass_if_negative ), ), )
def test_validation_should_fail_pre_sds_when_regex_is_invalid(self): for regex_case in failing_regex_validation_cases(): arguments = self.conf.arguments(NameRegexVariant.of(regex_case.regex_string)) for expectation_type in ExpectationType: with self.subTest(expectation_type=expectation_type, validation_case=regex_case.case_name): integration_check.CHECKER__PARSE_SIMPLE.check__w_source_variants( self, arguments= arguments.as_arguments, input_= ARBITRARY_MODEL, arrangement= arrangement_w_tcds( symbols=SymbolContext.symbol_table_of_contexts(regex_case.symbols) ), expectation= Expectation( ParseExpectation( symbol_references=asrt.matches_sequence(regex_case.reference_assertions), ), ExecutionExpectation( validation=regex_case.expectation ), ) )
def runTest(self): # ARRANGE # matcher = LineMatcherSymbolContext.of_primitive_constant( 'line_matcher_symbol', False, ) line_matcher_arg = lm_args.SymbolReference(matcher.name) arguments = st_args.syntax_for_filter_transformer(str(line_matcher_arg)) # ACT & ASSERT # for may_depend_on_external_resources in [False, True]: with self.subTest(may_depend_on_external_resources=may_depend_on_external_resources): integration_check.CHECKER__PARSE_SIMPLE.check( self, remaining_source(arguments), model_constructor.empty(self, may_depend_on_external_resources=may_depend_on_external_resources), arrangement_w_tcds( symbols=matcher.symbol_table ), expectation_of_successful_filter_execution( symbol_references=asrt.matches_singleton_sequence( matcher.reference_assertion ), output_lines=[], ) )
def test(self): # ARRANGE # reg_ex_pattern = 'const_pattern' arguments = st_args.syntax_for_filter_transformer(str( lm_args.Contents(sm_args.Matches(reg_ex_pattern))) ) lines = [ reg_ex_pattern + '\n', 'non matching line', ] expected_lines = [ reg_ex_pattern + '\n', ] # ACT & ASSERT # integration_check.CHECKER__PARSE_SIMPLE.check__w_source_variants( self, Arguments(arguments), model_constructor.of_lines(self, lines), arrangement_w_tcds(), expectation_of_successful_filter_execution( output_lines=expected_lines, symbol_references=asrt.is_empty_sequence, ) )
def test_SHOULD_not_be_identity_transformer(self): # ARRANGE # matcher = LineMatcherSymbolContext.of_primitive_constant( 'line_matcher_symbol', False, ) line_matcher_arg = lm_args.SymbolReference(matcher.name) arguments = st_args.syntax_for_filter_transformer(str(line_matcher_arg)) # ACT & ASSERT # integration_check.CHECKER__PARSE_SIMPLE.check__w_source_variants( self, Arguments(arguments), model_constructor.of_lines(self, []), arrangement_w_tcds( symbols=matcher.symbol_table ), expectation_of_successful_filter_execution( symbol_references=asrt.matches_singleton_sequence( matcher.reference_assertion ), output_lines=[], ) )
def runTest(self): # ARRANGE # name_of_referenced_symbol = 'FILE_MATCHER_WITH_VALIDATION_FAILURE' selection_is_empty_arguments = fsm_args.Selection( fm_args2.SymbolReference(name_of_referenced_symbol), args.Empty()) for case in validation_cases.failing_validation_cases( name_of_referenced_symbol): symbol_context = case.value.symbol_context selection_is_empty_source = selection_is_empty_arguments.as_remaining_source # ACT & ASSERT # with self.subTest(case.name): integration_check.CHECKER__PARSE_FULL.check( self, selection_is_empty_source, model.arbitrary_model(), arrangement_w_tcds(symbols=symbol_context.symbol_table, ), Expectation( ParseExpectation(symbol_references=symbol_context. references_assertion, ), ExecutionExpectation( validation=case.value.expectation, ), ), )
def runTest(self): # ARRANGE # contents_cases: Sequence[NameAndValue[fs.FileSystemElements]] = [ NameAndValue( 'empty', (), ), NameAndValue( 'non-empty', [fs.File.empty('empty-file.txt')], ), ] for contents_case in contents_cases: symbol = FilesSourceSymbolContext.of_primitive( 'SYMBOL_NAME', FilesSourceThatWritesFileSystemElements(contents_case.value), ) # ACT & ASSERT # integration_check.CHECKER.check__abs_stx__layout__std_source_variants( self, symbol.abstract_syntax, models.empty(), arrangement_w_tcds( symbols=symbol.symbol_table, ), MultiSourceExpectation( symbol_references=symbol.references_assertion, execution=ExecutionExpectation( main_result=asrt_fs.dir_contains_exactly_2(contents_case.value) ) ), sub_test_identifiers={ 'contents': contents_case.name, } )
def _check_( self, instruction_source: ParseSource, model: ModelConstructor, etc: ExpectationTypeConfigForNoneIsSuccess, main_result_for_positive_expectation: PassOrFail, root_dir_of_dir_contents: RelativityOptionConfiguration, contents_of_relativity_option_root: DirContents = empty_dir_contents(), test_case_name: str = '', following_symbols_setup: SymbolsArrEx = SymbolsArrEx.empty()): with self.put.subTest(case_name=test_case_name, expectation_type=etc.expectation_type.name, arguments=instruction_source.source_string): integration_check.CHECKER__PARSE_FULL.check( self.put, instruction_source, model, arrangement_w_tcds( pre_population_action=MAKE_CWD_OUTSIDE_OF_EVERY_REL_OPT_DIR, tcds_contents=root_dir_of_dir_contents. populator_for_relativity_option_root( contents_of_relativity_option_root), symbols=_symbol_table_of(root_dir_of_dir_contents.symbols, following_symbols_setup), ), Expectation( ParseExpectation(symbol_references=following_symbols_setup. expected_references_assertion, ), ExecutionExpectation(main_result=etc.main_result( main_result_for_positive_expectation), ), ))
def test_regular_file(self): file_name = 'destination.txt' file_name_syntax = StringLiteralAbsStx(file_name, QuoteType.HARD) explicit_file_contents = str_src_abs_stx.StringSourceOfStringAbsStx.of_plain( StringLiteralAbsStx.empty_string() ) file_spec_syntax = regular_file_spec( file_name_syntax, FileContentsExplicitAbsStx(ModificationType.APPEND, explicit_file_contents), ) for dir_contents_case in file_must_exist_as_regular(file_name): with self.subTest(dir_contents=dir_contents_case.name): integration_check.CHECKER.check__abs_stx( self, LiteralFilesSourceAbsStx([file_spec_syntax]), dir_contents_case.value, arrangement_w_tcds(), Expectation( parse=IS_AT_END_OF_1ST_LNE, execution=ExecutionExpectation( is_hard_error=asrt_text_doc.is_any_text(), ) ), )
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_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 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 environment_exe_case( environment: Dict[str, str], program_symbol_name: str, ) -> NExArr[PrimAndExeExpectation[MatcherWTrace, MatchingResult], Arrangement]: py_file = File( 'environment-vars-check.py', py_programs. pgm_that_exists_with_zero_exit_code_iff_environment_vars_not_included( environment)) py_file_rel_opt_conf = rel_opt.conf_rel_any(RelOptionType.REL_TMP) py_file_conf = py_file_rel_opt_conf.named_file_conf(py_file.name) program_symbol = ProgramSymbolContext.of_sdv( program_symbol_name, program_sdvs.interpret_py_source_file_that_must_exist( py_file_conf.path_sdv)) return NExArr( 'Environment: {}'.format(repr(environment)), PrimAndExeExpectation.of_exe( main_result=asrt_run.is_result_for_py_interpreter( py_run_programs.EXIT_CODE_FOR_SUCCESS)), arrangement_w_tcds( tcds_contents=py_file_rel_opt_conf. populator_for_relativity_option_root(DirContents([py_file])), symbols=program_symbol.symbol_table, process_execution=ProcessExecutionArrangement( process_execution_settings=ProcessExecutionSettings. with_environ(environment))))
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 runTest(self): # ARRANGE # model_contents = 'the contents of stdin of program' stdin_string_source_syntax = string_source_abs_stx.StringSourceOfStringAbsStx.of_str_hard( model_contents, ) for output_file in ProcOutputFile: for ignore_exit_code in [False, True]: with self.subTest(output_file=output_file, ignore_exit_code=ignore_exit_code): test_setup = StdinCheckViaCopyToOutputFileTestSetup( output_file) # ACT & ASSERT # CHECKER.check__abs_stx__wo_input( self, StringSourceOfProgramAbsStx( output_file, FullProgramAbsStx( test_setup.program_that_copies_stdin_syntax(), stdin=stdin_string_source_syntax), ignore_exit_code, ), arrangement_w_tcds( symbols=SymbolContext.symbol_table_of_contexts( test_setup.symbols), ), Expectation.of_prim__const( parse=ParseExpectation( symbol_references=SymbolContext. references_assertion_of_contexts( test_setup.symbols)), primitive=asrt_string_source. pre_post_freeze__identical( asrt_contents.matches__str( asrt.equals(model_contents))), ), )
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 test_stdin_is_contents_of_string_source_WHEN_program_defines_single_stdin( self): # ARRANGE # test_setup = SingleStdinOfProgramTestSetup(self, exit_code=0) for output_file in ProcOutputFile: for pgm_and_args_case in pgm_and_args_cases.cases_w_and_wo_argument_list__including_program_reference( ): for ignore_exit_code in [False, True]: with self.subTest(output_file=output_file, program=pgm_and_args_case.name, ignore_exit_code=ignore_exit_code): # ACT & ASSERT # CHECKER.check__abs_stx__layouts__source_variants__wo_input( self, equivalent_source_variants__for_expr_parse__s__nsc, StringSourceOfProgramAbsStx( output_file, test_setup.program_w_stdin_syntax( pgm_and_args_case.pgm_and_args), ignore_exit_code, ), 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.of_prim__const( symbol_references=pgm_and_args_case. references_assertion, primitive=IS_EMPTY_STRING_SOURCE, ), )
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 check__w_access_of_all_model_properties( put: unittest.TestCase, range_expr: Sequence[range_args.Range], input_and_expected: InputAndExpectedWExtDeps, ): arguments = args.filter_line_nums__multi(range_expr) for source_may_depend_on_external_resources in [False, True]: with put.subTest(may_depend_on_external_resources= source_may_depend_on_external_resources): integration_check.CHECKER__PARSE_SIMPLE.check( put, arguments.as_remaining_source, model_constructor.of_lines( put, input_and_expected.input, may_depend_on_external_resources= source_may_depend_on_external_resources, ), arrangement_w_tcds(), integration_check.expectation_of_successful_execution( symbol_references=asrt.is_empty_sequence, output_lines=input_and_expected.expected.lines, may_depend_on_external_resources=input_and_expected. expected.may_dep_on_ext_rsrc( source_may_depend_on_external_resources), frozen_may_depend_on_external_resources=asrt.anything_goes( ), is_identity_transformer=False, ))
def _doTest(self, maybe_not: ExpectationTypeConfigForNoneIsSuccess): expected_content_line_template = 'expected content line, with {symbol} ref' def expected_content(symbol_content: str) -> str: return expected_content_line_template.format(symbol=symbol_content) symbol = StringConstantSymbolContext('symbol_name', 'the symbol value') self._check( test_configuration.source_for( args('{maybe_not} {equals} <<EOF', maybe_not=maybe_not.nothing__if_positive__not_option__if_negative), [expected_content(symbol.name__sym_ref_syntax), 'EOF', 'following line']), model_constructor.of_str(self, lines_content([expected_content(symbol.str_value)])), arrangement_w_tcds( post_population_action=MK_SUB_DIR_OF_ACT_AND_MAKE_IT_CURRENT_DIRECTORY, symbols=symbol.symbol_table), Expectation( ParseExpectation( source=asrt_source.is_at_end_of_line(3), symbol_references=asrt.matches_sequence([ symbol.reference_assertion__w_str_rendering ]), ), ExecutionExpectation( main_result=maybe_not.pass__if_positive__fail__if_negative, ), ), )
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_that_symbols_from_arrangement_exist_in_environment(self): symbol = StringConstantSymbolContext('symbol_name', 'the symbol value') symbol_table_of_arrangement = symbol.symbol_table expected_symbol_table = symbol.symbol_table expectation = asrt_sym.equals_symbol_table(expected_symbol_table) sdv_that_checks_symbols = MatcherSdvThatAssertsThatSymbolsAreAsExpected(self, expectation) cases = [ NameAndValue('arrangement without tcds', arrangement_wo_tcds( symbol_table_of_arrangement) ), NameAndValue('arrangement with tcds', arrangement_w_tcds( symbols=symbol_table_of_arrangement) ), ] for arrangement in cases: with self.subTest(arrangement.name): self._check___single_and_multi( utils.single_line_arguments(), ARBITRARY_MODEL, _constant_line_matcher_type_parser_of_matcher_sdv(sdv_that_checks_symbols), arrangement.value, Expectation(), )
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 mk_arrangement__executable_file(symbols: SymbolTable) -> Arrangement: return arrangement_w_tcds( symbols=symbols, tcds_contents=executable_file_relativity. populator_for_relativity_option_root( fs.DirContents( [fs.executable_file(executable_program_file_name)])))