def test_symbol_reference_on_command_line_SHOULD_be_reported_and_used_in_execution(self): symbol = NameAndValue('symbol_name', 'symbol value') string_to_print_template = 'constant and {symbol}' expected_output_template = string_to_print_template + '\n' shell_source_line = shell_commands.command_that_prints_to_stdout( string_to_print_template.format(symbol=symbol_reference_syntax_for_name(symbol.name)) ) act_phase_instructions = [instr([shell_command_source_line_for(shell_source_line)])] expected_symbol_references = [ SymbolReference(symbol.name, is_any_data_type()), ] check_execution( self, sut.Parser(), act_phase_instructions, Arrangement( symbol_table=SymbolTable({ symbol.name: data_symbol_utils.string_constant_container(symbol.value) }) ), Expectation( symbol_usages=equals_symbol_references(expected_symbol_references), sub_process_result_from_execute= pr.stdout(asrt.equals(expected_output_template.format(symbol=symbol.value))) ), )
def test_symbol_reference_on_command_line_SHOULD_be_reported_and_used_in_execution( self): symbol = StringConstantSymbolContext('symbol_name', 'symbol value') string_to_print_template = 'constant and {symbol}' expected_output_template = string_to_print_template + '\n' shell_source_line = shell_commands.command_that_prints_to_stdout( string_to_print_template.format( symbol=symbol.name__sym_ref_syntax)) act_phase_instructions = [ instr([shell_command_source_line_for(shell_source_line)]) ] check_execution( self, sut.actor(), act_phase_instructions, arrangement_w_tcds(symbol_table=symbol.symbol_table), Expectation(symbol_usages=asrt.matches_singleton_sequence( symbol.reference_assertion__w_str_rendering), post_sds=PostSdsExpectation.constant( sub_process_result_from_execute=pr.stdout( asrt.equals( expected_output_template.format( symbol=symbol.str_value))))), )
def runTest(self): symbol = NameAndValue('symbol_name', 'the symbol value') program_that_prints_value_of_symbol = 'print("{symbol}")' single_source_line = program_that_prints_value_of_symbol.format( symbol=symbol_reference_syntax_for_name(symbol.name), ) expected_output = symbol.value + '\n' self._check( single_source_line, Arrangement( symbol_table=SymbolTable({ symbol.name: su.string_constant_container(symbol.value), }) ), Expectation( symbol_usages=equals_symbol_references([ SymbolReference(symbol.name, is_any_data_type()), ]), sub_process_result_from_execute=pr.stdout(asrt.Equals(expected_output, 'program output')), ))
def runTest(self): path_suffix = 'the-path-suffix' symbol = NameAndValue('symbol_name', file_refs.rel_act(file_refs.constant_path_part(path_suffix))) program_that_prints_value_of_symbol = 'print("{symbol}")' single_source_line = program_that_prints_value_of_symbol.format( symbol=symbol_reference_syntax_for_name(symbol.name), ) self._check( single_source_line, Arrangement( symbol_table=SymbolTable({ symbol.name: su.file_ref_constant_container(symbol.value), }) ), Expectation( symbol_usages=equals_symbol_references([ SymbolReference(symbol.name, is_any_data_type()), ]), sub_process_result_from_execute=pr.stdout(str_asrt.contains(path_suffix)), ))
def test_possibility_to_have_sds_path_references_in_argument(self): file_name_of_referenced_file = 'file-name.txt' symbol = ConstantSuffixPathDdvSymbolContext( 'symbol_name', RelOptionType.REL_TMP, file_name_of_referenced_file) executable = 'the-executable' command_line = '{executable} {symbol}'.format( executable=executable, symbol=symbol.name__sym_ref_syntax, ) arrangement = arrangement_w_tcds( hds_contents=relativity_configurations.ATC_FILE. populator_for_relativity_option_root__hds( fs.DirContents([ fs.python_executable_file( executable, PYTHON_PROGRAM_THAT_PRINTS_COMMAND_LINE_ARGUMENTS_ON_SEPARATE_LINES ) ])), symbol_table=symbol.symbol_table) expectation = Expectation( execute=eh_assertions.is_exit_code(0), symbol_usages=asrt.matches_singleton_sequence( symbol.reference_assertion__w_str_rendering), post_sds=PostSdsExpectation.constant( sub_process_result_from_execute=pr.stdout( str_asrt.contains(file_name_of_referenced_file))), ) check_execution(self, sut.actor(), [instr([command_line])], arrangement, expectation)
def test_symbol_value_with_space_SHOULD_be_given_as_single_argument_to_program( self): symbol = StringConstantSymbolContext('symbol_name', 'symbol value with space') expected_output = lines_content([symbol.str_value]) executable_file_name = 'the-executable_file_name' command_line = '{executable_file_name} {symbol}'.format( executable_file_name=executable_file_name, symbol=symbol.name__sym_ref_syntax, ) arrangement = arrangement_w_tcds( hds_contents=relativity_configurations.ATC_FILE. populator_for_relativity_option_root__hds( fs.DirContents([ fs.python_executable_file( executable_file_name, PYTHON_PROGRAM_THAT_PRINTS_COMMAND_LINE_ARGUMENTS_ON_SEPARATE_LINES ) ])), symbol_table=symbol.symbol_table) expectation = Expectation( symbol_usages=asrt.matches_sequence( [symbol.reference_assertion__w_str_rendering]), execute=eh_assertions.is_exit_code(0), post_sds=PostSdsExpectation. constant(sub_process_result_from_execute=pr.stdout( asrt.Equals(expected_output, 'CLI arguments, one per line'))), ) check_execution(self, sut.actor(), [instr([command_line])], arrangement, expectation)
def _main_program_test_cases() -> list: return [ ProcessTestCase( 'Generation of html-doc SHOULD exit with 0 exit code ' 'AND output html', PlainArrangement([HELP_COMMAND] + arguments_for.html_doc()), asrt.And([ pr.is_result_for_exit_code(0), pr.stdout(begins_with(DOCTYPE_XHTML1_0)) ])) ]
def _main_program_test_cases() -> list: return [ ProcessTestCase('Generation of html-doc SHOULD exit with 0 exit code ' 'AND output html', PlainArrangement([HELP_COMMAND] + arguments_for.html_doc()), asrt.And([ pr.is_result_for_exit_code(0), pr.stdout(begins_with(DOCTYPE_XHTML1_0)) ]) ) ]
def test_multiple_symbol_references_in_executable(self): sub_dir_of_home = 'sub-dir' dir_symbol = NameAndValue('dir_symbol_name', file_refs.rel_home_act(file_refs.constant_path_part(sub_dir_of_home))) executable_file_name_symbol = NameAndValue('executable_file_name_symbol_name', 'the-executable-file') argument = 'argument_string' expected_output = lines_content([argument]) command_line = '{dir}/{file_name} {argument} '.format( dir=symbol_reference_syntax_for_name(dir_symbol.name), file_name=symbol_reference_syntax_for_name(executable_file_name_symbol.name), argument=argument, ) executable_file = fs.python_executable_file( executable_file_name_symbol.value, PYTHON_PROGRAM_THAT_PRINTS_COMMAND_LINE_ARGUMENTS_ON_SEPARATE_LINES) arrangement = Arrangement( hds_contents=contents_in(RelHomeOptionType.REL_HOME_ACT, fs.DirContents([ fs.Dir(sub_dir_of_home, [executable_file]) ])), symbol_table=SymbolTable({ dir_symbol.name: su.file_ref_constant_container(dir_symbol.value), executable_file_name_symbol.name: su.string_constant_container(executable_file_name_symbol.value), }) ) expectation = Expectation( result_of_execute=eh_assertions.is_exit_code(0), sub_process_result_from_execute=pr.stdout(asrt.Equals(expected_output, 'CLI arguments, one per line')), symbol_usages=equals_symbol_references([ SymbolReference(dir_symbol.name, path_or_string_reference_restrictions(PATH_RELATIVITY_VARIANTS_FOR_FILE_TO_RUN)), SymbolReference(executable_file_name_symbol.name, PATH_COMPONENT_STRING_REFERENCES_RESTRICTION), ]), ) check_execution(self, sut.Parser(), [instr([command_line])], arrangement, expectation)
def runTest(self): sub_dir_of_home = 'sub-dir' dir_symbol = ConstantSuffixPathDdvSymbolContext('dir_symbol_name', RelOptionType.REL_HDS_ACT, sub_dir_of_home, PATH_RELATIVITY_VARIANTS_FOR_FILE_TO_RUN) source_file_name_symbol = StringConstantSymbolContext('source_file_name_symbol_name', 'the-source-file.py') argument = 'argument_string' expected_output = lines_content([argument]) command_line = '{dir}/{file_name} {argument} '.format( dir=dir_symbol.name__sym_ref_syntax, file_name=source_file_name_symbol.name__sym_ref_syntax, argument=argument, ) executable_file = fs.File( source_file_name_symbol.str_value, PYTHON_PROGRAM_THAT_PRINTS_COMMAND_LINE_ARGUMENTS_ON_SEPARATE_LINES) arrangement = arrangement_w_tcds( hds_contents=contents_in(RelHdsOptionType.REL_HDS_ACT, fs.DirContents([ fs.Dir(sub_dir_of_home, [executable_file]) ])), symbol_table=SymbolContext.symbol_table_of_contexts([ dir_symbol, source_file_name_symbol, ]) ) expectation = Expectation( symbol_usages=asrt.matches_sequence([ dir_symbol.reference_assertion__path_or_string, source_file_name_symbol.reference_assertion__path_component, ]), execute=eh_assertions.is_exit_code(0), post_sds=PostSdsExpectation.constant( sub_process_result_from_execute=pr.stdout(asrt.Equals(expected_output, 'CLI arguments, one per line')) ), ) self._check(command_line, arrangement, expectation)
def test_multiple_symbol_references_in_executable(self): sub_dir_of_home = 'sub-dir' dir_symbol = ConstantSuffixPathDdvSymbolContext( 'dir_symbol_name', RelOptionType.REL_HDS_ACT, sub_dir_of_home, PATH_RELATIVITY_VARIANTS_FOR_FILE_TO_RUN) executable_file_name_symbol = StringConstantSymbolContext( 'executable_file_name_symbol_name', 'the-executable-file') argument = 'argument_string' expected_output = lines_content([argument]) command_line = '{dir}/{file_name} {argument} '.format( dir=dir_symbol.name__sym_ref_syntax, file_name=executable_file_name_symbol.name__sym_ref_syntax, argument=argument, ) executable_file = fs.python_executable_file( executable_file_name_symbol.str_value, PYTHON_PROGRAM_THAT_PRINTS_COMMAND_LINE_ARGUMENTS_ON_SEPARATE_LINES ) arrangement = arrangement_w_tcds( hds_contents=relativity_configurations.ATC_FILE. populator_for_relativity_option_root__hds( fs.DirContents([fs.Dir(sub_dir_of_home, [executable_file])])), symbol_table=SymbolContext.symbol_table_of_contexts([ dir_symbol, executable_file_name_symbol, ])) expectation = Expectation( symbol_usages=asrt.matches_sequence([ dir_symbol.reference_assertion__path_or_string, executable_file_name_symbol. reference_assertion__string__w_all_indirect_refs_are_strings, ]), execute=eh_assertions.is_exit_code(0), post_sds=PostSdsExpectation. constant(sub_process_result_from_execute=pr.stdout( asrt.Equals(expected_output, 'CLI arguments, one per line'))), ) check_execution(self, sut.actor(), [instr([command_line])], arrangement, expectation)
def _non_entities_help() -> list: return [ ProcessTestCase( 'WHEN command line arguments are invalid THEN' ' exit code SHOULD indicate this' ' AND stdout SHOULD be empty', HelpInvokation(['too', 'many', 'arguments', ',', 'indeed']), asrt.And([ pr.is_result_for_exit_code(exit_codes.EXIT_INVALID_USAGE), pr.stdout(is_empty()) ])), ProcessTestCase('help for "program" SHOULD be successful', HelpInvokation(arguments_for.program()), RESULT_IS_SUCCESSFUL), ProcessTestCase('help for "help" SHOULD be successful', HelpInvokation(arguments_for.help_help()), RESULT_IS_SUCCESSFUL), ]
def _non_entities_help() -> list: return [ ProcessTestCase('WHEN command line arguments are invalid THEN' ' exit code SHOULD indicate this' ' AND stdout SHOULD be empty', HelpInvokation(['too', 'many', 'arguments', ',', 'indeed']), asrt.And([ pr.is_result_for_exit_code(exit_codes.EXIT_INVALID_USAGE), pr.stdout(is_empty()) ])), ProcessTestCase('help for "program" SHOULD be successful', HelpInvokation(arguments_for.program()), RESULT_IS_SUCCESSFUL), ProcessTestCase('help for "help" SHOULD be successful', HelpInvokation(arguments_for.help_help()), RESULT_IS_SUCCESSFUL), ]
def runTest(self): symbol = ConstantSuffixPathDdvSymbolContext('symbol_name', RelOptionType.REL_ACT, 'the-path-suffix') program_that_prints_value_of_symbol = 'print("{symbol}")' single_source_line = program_that_prints_value_of_symbol.format( symbol=symbol.name__sym_ref_syntax, ) self._check( single_source_line, arrangement_w_tcds(symbol_table=symbol.symbol_table), Expectation( symbol_usages=asrt.matches_singleton_sequence( symbol.reference_assertion__w_str_rendering), post_sds=PostSdsExpectation.constant( sub_process_result_from_execute=asrt_pr.stdout( str_asrt.contains(symbol.path_suffix))), ))
def test_string_symbol_reference_in_executable_and_argument(self): symbol_for_executable = StringConstantSymbolContext( 'executable_symbol_name', 'the-executable') argument_symbol = StringConstantSymbolContext('argument_symbol_name', 'string-constant') expected_output = lines_content([argument_symbol.str_value]) command_line = '{executable} {argument} '.format( executable=symbol_for_executable.name__sym_ref_syntax, argument=argument_symbol.name__sym_ref_syntax, ) arrangement = arrangement_w_tcds( hds_contents=relativity_configurations.ATC_FILE. populator_for_relativity_option_root__hds( fs.DirContents([ fs.python_executable_file( symbol_for_executable.str_value, PYTHON_PROGRAM_THAT_PRINTS_COMMAND_LINE_ARGUMENTS_ON_SEPARATE_LINES ) ])), symbol_table=SymbolContext.symbol_table_of_contexts([ symbol_for_executable, argument_symbol, ])) expectation = Expectation( execute=eh_assertions.is_exit_code(0), symbol_usages=asrt.matches_sequence([ symbol_for_executable.reference_assertion__path_or_string( PATH_RELATIVITY_VARIANTS_FOR_FILE_TO_RUN), argument_symbol.reference_assertion__w_str_rendering, ]), post_sds=PostSdsExpectation. constant(sub_process_result_from_execute=pr.stdout( asrt.Equals(expected_output, 'CLI arguments, one per line'))), ) check_execution(self, sut.actor(), [instr([command_line])], arrangement, expectation)
def test_symbol_reference_in_arguments(self): list_symbol = NameAndValue('list_symbol_name', ['first element', 'second element']) string_constant = 'string-constant' expected_output = lines_content(['string-constant'] + list_symbol.value) executable = 'the-executable' command_line = '{executable} {string_constant} {list_symbol}'.format( executable=executable, string_constant=string_constant, list_symbol=symbol_reference_syntax_for_name(list_symbol.name), ) arrangement = Arrangement( hds_contents=contents_in(RelHomeOptionType.REL_HOME_ACT, fs.DirContents([ fs.python_executable_file( executable, PYTHON_PROGRAM_THAT_PRINTS_COMMAND_LINE_ARGUMENTS_ON_SEPARATE_LINES) ])), symbol_table=SymbolTable({ list_symbol.name: su.list_value_constant_container(lv.list_value_of_string_constants(list_symbol.value)), }) ) expectation = Expectation( result_of_execute=eh_assertions.is_exit_code(0), sub_process_result_from_execute=pr.stdout(asrt.Equals(expected_output, 'CLI arguments, one per line')), symbol_usages=equals_symbol_references( [SymbolReference(list_symbol.name, is_any_data_type())] ) ) check_execution(self, sut.Parser(), [instr([command_line])], arrangement, expectation)
def runTest(self): symbol_for_source_file = NameAndValue('source_file_symbol_name', 'the-source-file.py') argument_symbol = NameAndValue('argument_symbol_name', 'string-constant') expected_output = lines_content([argument_symbol.value]) command_line = '{source_file} {argument} '.format( source_file=symbol_reference_syntax_for_name(symbol_for_source_file.name), argument=symbol_reference_syntax_for_name(argument_symbol.name), ) arrangement = Arrangement( hds_contents=contents_in(RelHomeOptionType.REL_HOME_ACT, fs.DirContents([ fs.File( symbol_for_source_file.value, PYTHON_PROGRAM_THAT_PRINTS_COMMAND_LINE_ARGUMENTS_ON_SEPARATE_LINES) ])), symbol_table=SymbolTable({ symbol_for_source_file.name: su.string_constant_container(symbol_for_source_file.value), argument_symbol.name: su.string_constant_container(argument_symbol.value), }) ) expectation = Expectation( result_of_execute=eh_assertions.is_exit_code(0), sub_process_result_from_execute=pr.stdout(asrt.Equals(expected_output, 'CLI arguments, one per line')), symbol_usages=equals_symbol_references([ SymbolReference(symbol_for_source_file.name, path_or_string_reference_restrictions(PATH_RELATIVITY_VARIANTS_FOR_FILE_TO_RUN)), SymbolReference(argument_symbol.name, is_any_data_type()), ]), ) self._check(command_line, arrangement, expectation)
def runTest(self): symbol = StringConstantSymbolContext('symbol_name', 'the symbol value') program_that_prints_value_of_symbol = 'print("{symbol}")' single_source_line = program_that_prints_value_of_symbol.format( symbol=symbol.name__sym_ref_syntax, ) expected_output = symbol.str_value + '\n' self._check( single_source_line, arrangement_w_tcds(symbol_table=symbol.symbol_table), Expectation( symbol_usages=asrt.matches_sequence([ symbol.reference_assertion__w_str_rendering, ]), post_sds=PostSdsExpectation.constant( sub_process_result_from_execute=asrt_pr.stdout( asrt.Equals(expected_output, 'program output'))), ))
def runTest(self): executor_constructor = sut.Parser() act_phase_instructions = [ instr(['system-under-test first-argument "quoted argument"']) ] arrangement = Arrangement( hds_contents=contents_in(RelHomeOptionType.REL_HOME_ACT, fs.DirContents([ fs.python_executable_file( 'system-under-test', PYTHON_PROGRAM_THAT_PRINTS_COMMAND_LINE_ARGUMENTS_ON_SEPARATE_LINES) ]))) expected_output = lines_content(['first-argument', 'quoted argument']) expectation = Expectation(result_of_execute=eh_assertions.is_exit_code(0), sub_process_result_from_execute=pr.stdout(asrt.Equals(expected_output, 'CLI arguments, one per line'))) check_execution(self, executor_constructor, act_phase_instructions, arrangement, expectation)
def test_string_symbol_reference_in_executable(self): symbol_for_executable = NameAndValue('executable_symbol_name', 'the-executable') string_constant = 'string-constant' expected_output = lines_content(['string-constant']) command_line = '{executable} {string_constant} '.format( executable=symbol_reference_syntax_for_name(symbol_for_executable.name), string_constant=string_constant, ) arrangement = Arrangement( hds_contents=contents_in(RelHomeOptionType.REL_HOME_ACT, fs.DirContents([ fs.python_executable_file( symbol_for_executable.value, PYTHON_PROGRAM_THAT_PRINTS_COMMAND_LINE_ARGUMENTS_ON_SEPARATE_LINES) ])), symbol_table=SymbolTable({ symbol_for_executable.name: su.string_constant_container(symbol_for_executable.value), }) ) expectation = Expectation( result_of_execute=eh_assertions.is_exit_code(0), sub_process_result_from_execute=pr.stdout(asrt.Equals(expected_output, 'CLI arguments, one per line')), symbol_usages=equals_symbol_references([ SymbolReference(symbol_for_executable.name, path_or_string_reference_restrictions(PATH_RELATIVITY_VARIANTS_FOR_FILE_TO_RUN)), ] ) ) check_execution(self, sut.Parser(), [instr([command_line])], arrangement, expectation)
def runTest(self): actor = sut.actor() act_phase_instructions = [ instr(['system-under-test first-argument "quoted argument"']) ] arrangement = arrangement_w_tcds( hds_contents=relativity_configurations.ATC_FILE. populator_for_relativity_option_root__hds( fs.DirContents([ fs.python_executable_file( 'system-under-test', PYTHON_PROGRAM_THAT_PRINTS_COMMAND_LINE_ARGUMENTS_ON_SEPARATE_LINES ) ]))) expected_output = lines_content(['first-argument', 'quoted argument']) expectation = Expectation( execute=eh_assertions.is_exit_code(0), post_sds=PostSdsExpectation. constant(sub_process_result_from_execute=pr.stdout( asrt.Equals(expected_output, 'CLI arguments, one per line')))) check_execution(self, actor, act_phase_instructions, arrangement, expectation)
def test_symbol_value_with_space_SHOULD_be_given_as_single_argument_to_program(self): symbol = NameAndValue('symbol_name', 'symbol value with space') expected_output = lines_content([symbol.value]) executable_file_name = 'the-executable_file_name' command_line = '{executable_file_name} {symbol}'.format( executable_file_name=executable_file_name, symbol=symbol_reference_syntax_for_name(symbol.name), ) arrangement = Arrangement( hds_contents=contents_in(RelHomeOptionType.REL_HOME_ACT, fs.DirContents([ fs.python_executable_file( executable_file_name, PYTHON_PROGRAM_THAT_PRINTS_COMMAND_LINE_ARGUMENTS_ON_SEPARATE_LINES) ])), symbol_table=SymbolTable({ symbol.name: su.string_constant_container(symbol.value), }) ) expectation = Expectation( result_of_execute=eh_assertions.is_exit_code(0), sub_process_result_from_execute=pr.stdout(asrt.Equals(expected_output, 'CLI arguments, one per line')), symbol_usages=equals_symbol_references( [SymbolReference(symbol.name, is_any_data_type())] ) ) check_execution(self, sut.Parser(), [instr([command_line])], arrangement, expectation)
def test_symbol_reference_in_arguments(self): list_symbol = ListConstantSymbolContext( 'list_symbol_name', ['first element', 'second element']) string_constant = 'string-constant' expected_output = lines_content(['string-constant'] + list_symbol.constant_list) executable = 'the-executable' command_line = '{executable} {string_constant} {list_symbol}'.format( executable=executable, string_constant=string_constant, list_symbol=list_symbol.name__sym_ref_syntax, ) arrangement = arrangement_w_tcds( hds_contents=relativity_configurations.ATC_FILE. populator_for_relativity_option_root__hds( fs.DirContents([ fs.python_executable_file( executable, PYTHON_PROGRAM_THAT_PRINTS_COMMAND_LINE_ARGUMENTS_ON_SEPARATE_LINES ) ])), symbol_table=list_symbol.symbol_table) expectation = Expectation( symbol_usages=asrt.matches_singleton_sequence( list_symbol.reference_assertion), execute=eh_assertions.is_exit_code(0), post_sds=PostSdsExpectation. constant(sub_process_result_from_execute=pr.stdout( asrt.Equals(expected_output, 'CLI arguments, one per line'))), ) check_execution(self, sut.actor(), [instr([command_line])], arrangement, expectation)
def test_possibility_to_have_sds_file_references_in_argument(self): file_name_of_referenced_file = 'file-name.txt' symbol = NameAndValue('symbol_name', file_refs.of_rel_option(RelOptionType.REL_TMP, file_refs.constant_path_part(file_name_of_referenced_file))) executable = 'the-executable' command_line = '{executable} {symbol}'.format( executable=executable, symbol=symbol_reference_syntax_for_name(symbol.name), ) arrangement = Arrangement( hds_contents=contents_in(RelHomeOptionType.REL_HOME_ACT, fs.DirContents([ fs.python_executable_file( executable, PYTHON_PROGRAM_THAT_PRINTS_COMMAND_LINE_ARGUMENTS_ON_SEPARATE_LINES) ])), symbol_table=SymbolTable({ symbol.name: su.file_ref_constant_container(symbol.value), }) ) expectation = Expectation( result_of_execute=eh_assertions.is_exit_code(0), sub_process_result_from_execute=pr.stdout(str_asrt.contains(file_name_of_referenced_file)), symbol_usages=equals_symbol_references( [SymbolReference(symbol.name, is_any_data_type())] ) ) check_execution(self, sut.Parser(), [instr([command_line])], arrangement, expectation)
def test_symbol_value_with_space_SHOULD_be_given_as_single_argument_to_program(self): symbol = StringConstantSymbolContext('symbol_name', 'symbol value with space') expected_output = lines_content([symbol.str_value]) source_file = 'the-source-file.py' command_line = '{source_file} {symbol}'.format( source_file=source_file, symbol=symbol.name__sym_ref_syntax, ) arrangement = integration_check.arrangement_w_tcds( hds_contents=contents_in(RelHdsOptionType.REL_HDS_ACT, fs.DirContents([ fs.File( source_file, PYTHON_PROGRAM_THAT_PRINTS_COMMAND_LINE_ARGUMENTS_ON_SEPARATE_LINES) ])), symbol_table=symbol.symbol_table ) expectation = integration_check.Expectation( symbol_usages=asrt.matches_sequence( [symbol.reference_assertion__w_str_rendering] ), execute=eh_assertions.is_exit_code(0), post_sds=PostSdsExpectation.constant( sub_process_result_from_execute=asrt_pr.stdout(asrt.Equals(expected_output, 'CLI arguments, one per line')) ), ) integration_check.check_execution(self, ACTOR_THAT_RUNS_PYTHON_PROGRAM_FILE, [instr([command_line])], arrangement, expectation)
from typing import List from exactly_lib.cli.definitions.common_cli_options import HELP_COMMAND from exactly_lib_test.test_resources.main_program.constant_arguments_check import Arrangement from exactly_lib_test.test_resources.value_assertions import process_result_assertions as pr from exactly_lib_test.test_resources.value_assertions import value_assertion as asrt from exactly_lib_test.test_resources.value_assertions.value_assertion_str import is_not_only_space class HelpInvokation(Arrangement): def __init__(self, help_arguments: List[str]): self.help_arguments = help_arguments def command_line_arguments(self) -> List[str]: return [HELP_COMMAND] + self.help_arguments RESULT_IS_SUCCESSFUL = asrt.And([pr.is_result_for_exit_code(0), pr.stdout(is_not_only_space())])
from typing import List from exactly_lib.cli.definitions.common_cli_options import HELP_COMMAND from exactly_lib_test.test_resources.main_program.constant_arguments_check import Arrangement from exactly_lib_test.test_resources.value_assertions import process_result_assertions as pr from exactly_lib_test.test_resources.value_assertions import value_assertion as asrt from exactly_lib_test.test_resources.value_assertions.value_assertion_str import is_not_only_space class HelpInvokation(Arrangement): def __init__(self, help_arguments: List[str]): self.help_arguments = help_arguments def command_line_arguments(self) -> List[str]: return [HELP_COMMAND] + self.help_arguments RESULT_IS_SUCCESSFUL = asrt.And( [pr.is_result_for_exit_code(0), pr.stdout(is_not_only_space())])