def fake_post_sds_environment() -> InstructionEnvironmentForPostSdsStep: sds = fake_sds() return InstructionEnvironmentForPostSdsStep( fake_hds(), ProcessExecutionSettings.with_empty_environ(), sds, TmpFileStorage(sds.internal_tmp_dir / 'instruction-dir', lambda path: DirFileSpaceThatDoNotCreateFiles(path)), SymbolTable.empty(), 2 ** 10, )
def resolving_env_w_custom_dir_space( sds: SandboxDs, mem_buff_size: int = 2**10, ) -> FullResolvingEnvironment: return FullResolvingEnvironment( SymbolTable.empty(), fake_tcds(), ApplicationEnvironment( OsServicesThatRaises(), proc_exe_env_for_test(), tmp_file_spaces.tmp_dir_file_space_for_test( sds.internal_tmp_dir / 'string-model-dir-for-test'), mem_buff_size, ))
def get_command_assertion(tcds: TestCaseDs) -> Assertion[Command]: symbols = SymbolTable.empty() return asrt_command.matches_command( asrt.anything_goes(), asrt.equals( interpreter_arguments_symbol.constant_list + [ str(relativity_configurations.ATC_FILE .named_file_conf(exe_file.name) .path_sdv .resolve(symbols) .value_of_any_dependency__d(tcds) .primitive ), argument_to_act_file, ] ) )
def check__abs_stx__expr_parse_source_variants( self, put: unittest.TestCase, syntax: AbstractSyntax, symbols: Optional[SymbolTable], expectation: Expectation[T], sub_test_identifiers: Mapping[str, Any] = MappingProxyType({}), ): if symbols is None: symbols = SymbolTable.empty() for formatting_case in abs_stx_utils.formatting_cases(syntax): for equivalent_source_case in equivalent_source_variants.expr_parse__s__nsc( formatting_case.value): with put.subTest( zz_formatting=formatting_case.name, zz_following_source_variant=equivalent_source_case. name, **sub_test_identifiers): parse_source = equivalent_source_case.source with token_stream_parser.from_parse_source( parse_source) as token_parser: # ACT sdv = self._parser.parse(token_parser) # ASSERT # equivalent_source_case.expectation.apply_with_message( put, parse_source, 'source after parse', ) expectation.symbol_references.apply_with_message( put, sdv.references, 'symbol references', ) expectation.sdv.apply_with_message( put, sdv, 'custom sdv expectation') # ACT # ddv = sdv.resolve(symbols) # ASSERT # expectation.ddv.apply_with_message( put, ddv, 'ddv', )
def test_literal(self): # ARRANGE # defined_name = symbol_syntax.A_VALID_SYMBOL_NAME create_file = fs.File('created-file.txt', 'contents of created file') literal_syntax = abs_stx.LiteralFilesSourceAbsStx([ abs_stx.regular_file_spec( StringLiteralAbsStx(create_file.name, QuoteType.HARD), abs_stx.FileContentsExplicitAbsStx( ModificationType.CREATE, StringSourceOfStringAbsStx.of_str(create_file.contents, QuoteType.HARD), ) ) ]) syntax = _syntax_of( literal_syntax, defined_name, ) arrangement = Arrangement.phase_agnostic() # EXPECTATION # expectation = _expect_definition_of( defined_name, SymbolTable.empty(), (), asrt.is_empty_sequence, asrt_fs.dir_contains_exactly_2([create_file]) ) # ACT & ASSERT # INSTRUCTION_CHECKER.check__abs_stx__std_layouts_and_source_variants( self, syntax, arrangement, expectation, )
def get_command_assertion(tcds: TestCaseDs) -> Assertion[Command]: symbols = SymbolTable.empty() return asrt_command.matches_command( asrt.anything_goes(), asrt.equals([ str(relativity_configurations.ATC_FILE .named_file_conf(exe_file.name) .path_sdv .resolve(symbols) .value_of_any_dependency__d(tcds) .primitive ), str(existing_path_relativity .named_file_conf(existing_path_argument.name) .path_sdv .resolve(symbols) .value_of_any_dependency__d(tcds) .primitive ), text_until_end_of_line, ]) )
def symbols(self, put: unittest.TestCase) -> SymbolTable: return SymbolTable.empty()