def _do_check( self, program: ProgramAbsStx, process_execution_w_stdin_check: ProcessExecutionArrangement, program_symbols: Sequence[SymbolContext], tcds_contents: tcds_populators.TcdsPopulator = tcds_populators.empty(), ): # ARRANGE # string_matcher_const_true = StringMatcherSymbolContext.of_primitive( 'CONSTANT_TRUE', ConstantMatcherWithCustomName('const true', True), ) symbols = list(program_symbols) + [string_matcher_const_true] copy_stdin_and_check_via_matcher = StdoutErrFromProgramAbsStx( program, string_matcher_const_true.abstract_syntax, ) checker = instruction_check.Checker(self.configuration.parser()) # ACT & ASSERT # checker.check__abs_stx__source_variants( self, copy_stdin_and_check_via_matcher, ArrangementPostAct2( symbols=SymbolContext.symbol_table_of_contexts(symbols), tcds=TcdsArrangementPostAct(tcds_contents=tcds_contents), process_execution=process_execution_w_stdin_check, ), MultiSourceExpectation(symbol_usages=SymbolContext. usages_assertion_of_contexts(symbols)), )
def runTest(self): # ARRANGE # contents_of_stdin = 'the contents of stdin' string_matcher_that_checks_model = StringMatcherSymbolContext.of_primitive( 'SM_THAT_CHECKS_MODEL', EqualsConstant(contents_of_stdin), ) checker = instruction_check.Checker(self.configuration.parser()) program_that_copies_stdin_to_output = ProgramOfPythonInterpreterAbsStx.of_execute_python_src_string( py_programs.copy_stdin_to__single_line( self.configuration.output_file())) copy_stdin_and_check_via_matcher = StdoutErrFromProgramAbsStx( FullProgramAbsStx(program_that_copies_stdin_to_output, stdin=StringSourceOfStringAbsStx.of_str( contents_of_stdin, QuoteType.HARD)), string_matcher_that_checks_model.abstract_syntax, ) # ACT & ASSERT # checker.check__abs_stx__source_variants( self, copy_stdin_and_check_via_matcher, ArrangementPostAct2( symbols=string_matcher_that_checks_model.symbol_table, ), MultiSourceExpectation( symbol_usages=string_matcher_that_checks_model.usages_assertion ), )
def _check( self, source: AbstractSyntax, arrangement: ArrangementPostAct2, expectation: MultiSourceExpectation, ): checker = instruction_check.Checker(self._conf().parser) checker.check__abs_stx__source_variants(self, source, arrangement, expectation)
MultipleExecutionCasesGenerator from exactly_lib_test.impls.types.file_matcher.test_resources.argument_building import FileMatcherArg from exactly_lib_test.tcfs.test_resources.ds_construction import TcdsArrangementPostAct, \ TcdsArrangement from exactly_lib_test.tcfs.test_resources.path_arguments import RelOptPathArgument from exactly_lib_test.test_case.result.test_resources import pfh_assertions as asrt_pfh, svh_assertions as asrt_svh from exactly_lib_test.test_case.test_resources.arrangements import ArrangementPostAct2 from exactly_lib_test.test_resources.argument_renderer import ArgumentElementsRenderer, \ OptionArgument from exactly_lib_test.test_resources.test_utils import NExArr from exactly_lib_test.test_resources.value_assertions import value_assertion as asrt from exactly_lib_test.test_resources.value_assertions.value_assertion import Assertion PARSER = sut.parser.Parser() INSTRUCTION_CHECKER = instruction_check.Checker(PARSER) RECURSION_OPTION_ARG = OptionArgument( file_or_dir_contents.RECURSIVE_OPTION.name) class ExecutorOfCaseGeneratorForDirContents(ExecutorOfCaseGenerator): def execute_single( self, put: unittest.TestCase, case: SingleCaseGenerator, ): INSTRUCTION_CHECKER.check_2( put, source=_arguments( case.model_file, case.arguments(),
from exactly_lib.impls.instructions.assert_ import contents_of_file as sut from exactly_lib_test.impls.instructions.assert_.test_resources import instruction_check from exactly_lib_test.section_document.test_resources import parse_checker CHECKER = instruction_check.Checker(sut.parser('the-instruction-name')) PARSE_CHECKER = parse_checker.Checker(sut.parser('the-instruction-name'))
def checker(self) -> instruction_check.Checker: return instruction_check.Checker(self.new_parser())