def runTest(self):
        # ARRANGE #

        program_with_ref_to_file_in_hds_ds = pgm_args.program(
            pgm_args.interpret_py_source_file(path_arguments.RelOptPathArgument('non-existing-file',
                                                                                RelOptionType.REL_HDS_CASE))
        )
        arguments = po_ab.from_program(program_with_ref_to_file_in_hds_ds,
                                       matcher_arguments.emptiness_matcher())

        # ACT & ASSERT #

        self._check(arguments,
                    ArrangementPostAct(),
                    Expectation(validation_pre_sds=asrt_svh.is_validation_error()))
Ejemplo n.º 2
0
 def test_check_zero_exit_code__rel_tmp(self):
     self._check_single_line_arguments_with_source_variants(
         args.sequence([
             pgm_args.interpret_py_source_file(
                 path_arguments.RelOptPathArgument('exit-with-value-on-command-line.py',
                                                   RelOptionType.REL_TMP)),
             0,
         ]).as_str,
         tcds_test.Arrangement(
             sds_contents_before=contents_in(RelSdsOptionType.REL_TMP,
                                             DirContents([
                                                 File('exit-with-value-on-command-line.py',
                                                      py_pgm_that_exits_with_1st_value_on_command_line(''))]))),
         tcds_test.Expectation(
             expected_action_result=result_assertions.equals(0, None)),
     )
    def runTest(self):
        # ARRANGE #

        program_with_ref_to_file_in_hds_ds = pgm_args.program(
            pgm_args.interpret_py_source_file(path_arguments.RelOptPathArgument('non-existing-file',
                                                                                RelOptionType.REL_ACT))
        )
        arguments = po_ab.from_program(program_with_ref_to_file_in_hds_ds,
                                       matcher_arguments.emptiness_matcher())

        # ACT & ASSERT #

        self._check(arguments,
                    ArrangementPostAct(),
                    Expectation(
                        main_result=asrt_pfh.is_hard_error__with_arbitrary_message())
                    )
Ejemplo n.º 4
0
def source_for_interpreting(relativity: RelOptionType,
                            file_name: str) -> ParseSource:
    return pgm_args.program(
        pgm_args.interpret_py_source_file(
            path_arguments.RelOptPathArgument(file_name,
                                              relativity))).as_remaining_source
Ejemplo n.º 5
0
    def runTest(self):
        # ARRANGE #
        actor = sut.actor(COMMAND_THAT_RUNS_PYTHON_PROGRAM_FILE)

        exe_file = fs.python_executable_file(
            'program-name',
            py_programs.exit_with_0()
        )
        text_until_end_of_line = 'some {}invalidly quoted text'.format(SOFT_QUOTE_CHAR)

        existing_path_relativity = relativity_options.conf_rel_hds(RelHdsOptionType.REL_HDS_CASE)

        existing_path_argument = path_arguments.RelOptPathArgument(
            'existing-path',
            existing_path_relativity.relativity,
        )
        act_contents = ab.sequence__r([
            ab.singleton(exe_file.name),
            program_arguments.existing_path(
                existing_path_argument
            ),
            program_arguments.remaining_part_of_current_line_as_literal(text_until_end_of_line),
        ])

        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,
                ])
            )

        act_instruction = instr([act_contents.as_str])
        executor_that_records_arguments = CommandExecutorThatRecordsArguments()
        # ACT & ASSERT #
        integration_check.check_execution(
            self,
            actor,
            [act_instruction],
            arrangement_w_tcds(
                process_execution=ProcessExecutionArrangement(
                    os_services=os_services_access.new_for_cmd_exe(executor_that_records_arguments)
                ),
                hds_contents=hds_populators.multiple([
                    relativity_configurations.ATC_FILE.populator_for_relativity_option_root__hds(
                        fs.DirContents([exe_file])
                    ),
                    existing_path_relativity.populator_for_relativity_option_root__hds(
                        fs.DirContents([fs.File.empty(existing_path_argument.name)])
                    ),
                ])
            ),
            Expectation(
                after_execution=ExecutedCommandAssertion(
                    executor_that_records_arguments,
                    get_command_assertion,
                )
            ),
        )