Ejemplo n.º 1
0
    def test_case(self) -> str:
        equals_builtin_symbol_value_matcher = str_matcher_args.Equals.eq_string(
            symbol_reference_syntax_for_name(
                self._name_of_checked_symbol)).as_arguments.as_single_string

        return lines_content([
            pgm_args.interpret_py_source_file(
                self.PY_PROGRAM_FILE_NAME).as_str,
            phase_header_line(phase_identifier.ASSERT),
            ' '.join((instruction_names.CONTENTS_OF_STDOUT_INSTRUCTION_NAME,
                      equals_builtin_symbol_value_matcher)),
        ])
Ejemplo n.º 2
0
    def test_check_non_zero_exit_code(self):
        self._check_single_line_arguments_with_source_variants(
            args.sequence([pgm_args.interpret_py_source_file('exit-with-value-on-command-line.py'),
                           2]).as_str,
            tcds_test.Arrangement(
                hds_contents_before=hds_case_dir_contents(DirContents([
                    File('exit-with-value-on-command-line.py',
                         py_pgm_that_exits_with_1st_value_on_command_line('on stderr'))]))),
            tcds_test.Expectation(
                expected_action_result=result_assertions.equals(2, 'on stderr'),

            )
        )
    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.º 4
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.º 6
0
    def runTest(self):
        # ARRANGE #

        source_w_relative_name_of_existing_file = args.interpret_py_source_file(
            'program.py')

        # ACT & ASSERT #

        integration_check.check_execution(
            self,
            sut.actor(),
            [
                instr(
                    source_w_relative_name_of_existing_file.as_arguments.lines)
            ],
            arrangement_w_tcds(),
            Expectation(validation=ValidationExpectationSvh.fails__pre_sds()),
        )
Ejemplo n.º 7
0
    def runTest(self):
        # ARRANGE #

        result = SubProcessResult(
            exitcode=5,
            stdout='output on stdout from existing py program file',
            stderr='output on stderr from existing py program file',
        )

        py_file = fs.File(
            'the-program.py',
            py_program.program_that_prints_and_exits_with_exit_code(result),
        )

        source_w_relative_name_of_existing_file = args.interpret_py_source_file(
            py_file.name)

        # ACT & ASSERT #

        integration_check.check_execution(
            self,
            sut.actor(),
            [
                instr(
                    source_w_relative_name_of_existing_file.as_arguments.lines)
            ],
            arrangement_w_tcds(
                hds_contents=relativity_configurations.PROGRAM_FILE.
                populator_for_relativity_option_root__hds(
                    DirContents([py_file]))),
            Expectation(execute=asrt_eh.is_exit_code(result.exitcode),
                        post_sds=PostSdsExpectation.constant(
                            sub_process_result_from_execute=asrt_proc_result.
                            matches_proc_result(
                                exit_code=asrt.equals(result.exitcode),
                                stdout=asrt.equals(result.stdout),
                                stderr=asrt.equals(result.stderr),
                            ))),
        )
Ejemplo n.º 8
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