예제 #1
0
    def runTest(self):
        # ARRANGE #

        source_file = fs.File.empty('source-file.src')

        python_interpreter_symbol = PathSymbolContext.of_sdv(
            'PYTHON_INTERPRETER_SYMBOL',
            path_sdvs.constant(
                path_ddvs.absolute_path(pathlib.Path(sys.executable))))

        interpreter_with_symbol_reference = command_sdvs.for_executable_file(
            python_interpreter_symbol.reference_sdv__path_or_string(
                relativity_configurations.INTERPRETER_FILE.relativity))

        arrangement = arrangement_w_tcds(
            symbol_table=python_interpreter_symbol.symbol_table,
            hds_contents=relativity_configurations.ATC_FILE.
            populator_for_relativity_option_root__hds(
                fs.DirContents([source_file])))
        expectation = Expectation(
            symbol_usages=asrt.matches_singleton_sequence(
                python_interpreter_symbol.reference_assertion__path_or_string),
            post_sds=PostSdsExpectation.constant(
                sub_process_result_from_execute=asrt_pr.sub_process_result(
                    exitcode=asrt.equals(0),
                    stdout=asrt.equals(''),
                    stderr=asrt.equals(''),
                )),
        )
        # ACT & ASSERT #
        check_execution(self, sut.actor(interpreter_with_symbol_reference),
                        [instr([])], arrangement, expectation)
예제 #2
0
    def runTest(self):
        # ARRANGE #

        source_file = fs.File.empty('source-file.src')
        a_dir = fs.Dir.empty('a-dir')

        interpreter_with_program_that_is_a_dir = command_sdvs.for_executable_file(
            path_sdvs.constant(
                path_ddvs.rel_hds(
                    relativity_configurations.INTERPRETER_FILE.
                    relativity_option_rel_hds,
                    path_ddvs.constant_path_part(a_dir.name))), )

        arrangement = arrangement_w_tcds(hds_contents=hds_populators.multiple([
            relativity_configurations.ATC_FILE.
            populator_for_relativity_option_root__hds(
                fs.DirContents([source_file])),
            relativity_configurations.INTERPRETER_FILE.
            populator_for_relativity_option_root__hds(fs.DirContents([a_dir])),
        ]))
        expectation = Expectation(
            validation=ValidationExpectationSvh.fails__pre_sds())
        # ACT & ASSERT #
        check_execution(self,
                        sut.actor(interpreter_with_program_that_is_a_dir),
                        [instr([source_file.name])], arrangement, expectation)
def _source_interpreter_with_system_command(
        cmd_and_args: List[str]) -> NameAndValue[Actor]:
    command_sdv = command_sdvs.for_system_program(
        string_sdvs.str_constant(cmd_and_args[0]),
        ArgumentsSdv(list_sdvs.from_str_constants(cmd_and_args[1:])),
    )
    return NameAndValue(actors.SOURCE_INTERPRETER_ACTOR.singular_name,
                        actor.actor(command_sdv))
예제 #4
0
 def runTest(self):
     actor = sut.actor(_command_for_non_existing_interpreter())
     empty_source = []
     check_execution(self,
                     actor,
                     empty_source,
                     arrangement_w_tcds(),
                     Expectation(
                         validation=ValidationExpectationSvh.fails__pre_sds()
                     )
                     )
예제 #5
0
 def runTest(self):
     # ARRANGE #
     for case in VALIDATION_CASES:
         with self.subTest(case.name):
             interpreter_arguments = arguments_sdvs.ref_to_path_that_must_exist(
                 path_sdvs.of_rel_option_with_const_file_name(
                     case.path_relativity, 'non-existing-file'))
             actor = sut.actor(
                 command_sdvs.for_executable_file(
                     path_sdvs.constant(
                         path_ddvs.absolute_file_name(sys.executable)),
                     interpreter_arguments))
             act_instruction = instr([])
             # ACT & ASSERT #
             integration_check.check_execution(
                 self,
                 actor,
                 [act_instruction],
                 arrangement_w_tcds(),
                 Expectation(validation=case.expectation),
             )
예제 #6
0
 def __init__(self):
     actor = sut.actor(python3.python_command())
     super().__init__(actor)
예제 #7
0
 def _check(self, source_line: str, arrangement: Arrangement,
            expectation: Expectation):
     check_execution(self, sut.actor(COMMAND_THAT_RUNS_PYTHON_PROGRAM_FILE),
                     [instr([source_line])], arrangement, expectation)
예제 #8
0
def _parse_source_actor(token_parser: TokenParser) -> NameAndValue[Actor]:
    act_interpreter = parse_act_interpreter.parser().parse_from_token_parser(
        token_parser)
    return NameAndValue(actors.SOURCE_INTERPRETER_ACTOR.singular_name,
                        actor.actor(act_interpreter))