def runTest(self): output_from_program = 'first second' transformer_of_program = transformers_setup.DELETE_INITIAL_WORD_TRANSFORMER transformer_of_instruction = transformers_setup.DUPLICATE_WORDS_TRANSFORMER program_that_outputs_something = pgm_args.program( pgm_args.interpret_py_source_line( self.configuration.py_source_for_print(output_from_program)), transformation=transformer_of_program.name) result_when_positive = pfh_expectation_type_config( ExpectationType.POSITIVE) self._check_positive_and_negated( result_when_positive, program_that_outputs_something, matcher_arguments.equals_matcher( ab.quoted_string('second second')), lambda main_result: Expectation( main_result=main_result, symbol_usages=asrt.matches_sequence([ is_reference_to_string_transformer__usage( transformer_of_program.name), is_reference_to_string_transformer__usage( transformer_of_instruction.name), ])), arrangement=ArrangementPostAct( symbols=transformers_setup.SYMBOL_TABLE), transformation=transformer_of_instruction.name)
def test_check_non_zero_exit_code(self): EXECUTION_CHECKER.check__w_source_variants( self, pgm_args.interpret_py_source_line('exit(1)').as_str, Arrangement.phase_agnostic(tcds=TcdsArrangement(), ), MultiSourceExpectation.phase_agnostic( main_result=result_assertions.equals(1, '')))
def test_check_non_zero_exit_code_with_output_to_stderr(self): python_program = 'import sys; sys.stderr.write("on stderr"); exit(2)' EXECUTION_CHECKER.check__w_source_variants( self, pgm_args.interpret_py_source_line(python_program).as_str, Arrangement.phase_agnostic(tcds=TcdsArrangement(), ), MultiSourceExpectation.phase_agnostic( main_result=result_assertions.equals(2, 'on stderr')))
def runTest(self): program_that_outputs_nothing = pgm_args.program( pgm_args.interpret_py_source_line( self.configuration.py_source_for_print(''))) result_when_positive = pfh_expectation_type_config( ExpectationType.POSITIVE) self._check_positive_and_negated( result_when_positive, program_that_outputs_nothing, matcher_arguments.emptiness_matcher(), lambda main_result: Expectation(main_result=main_result))
def runTest(self): # ARRANGE # program = pgm_args.program( pgm_args.interpret_py_source_line('exit(0)') ) no_matcher = [] arguments = po_ab.from_program(program, no_matcher) source = arguments.as_remaining_source with self.assertRaises(SingleInstructionInvalidArgumentException): # ACT # self.configuration.parser().parse(ARBITRARY_FS_LOCATION_INFO, source)
def runTest(self): # ARRANGE # symbol_in_program_source = NameAndValue('SYMBOL_IN_PROGRAM_SOURCE', data_restrictions_assertions.is__w_str_rendering()) symbol_in_matcher = NameAndValue('SYMBOL_IN_MATCHER', ss_references.IS_STRING_SOURCE_OR_STRING_REFERENCE_RESTRICTION) symbol_in_transformer_of_program = NameAndValue('SYMBOL_IN_TRANSFORMER_OF_PROGRAM', is_reference_restrictions__value_type( [ValueType.STRING_TRANSFORMER])) symbol_in_transformer_of_instruction = NameAndValue('SYMBOL_IN_TRANSFORMER_OF_INSTRUCTION', is_reference_restrictions__value_type( [ValueType.STRING_TRANSFORMER])) program_with_ref_to_symbols = pgm_args.program( pgm_args.interpret_py_source_line( self.configuration.py_source_for_print( symbol_reference_syntax_for_name(symbol_in_program_source.name))), transformation=symbol_in_transformer_of_program.name ) matcher_with_ref_to_symbol = matcher_arguments.equals_matcher(SymbolReferenceArgument(symbol_in_matcher.name)) arguments = po_ab.from_program(program_with_ref_to_symbols, matcher_with_ref_to_symbol, transformation=symbol_in_transformer_of_instruction.name) symbol_usages_assertion = asrt.matches_sequence([ matches_reference(symbol_in_program_source), matches_reference(symbol_in_transformer_of_program), matches_reference(symbol_in_transformer_of_instruction), matches_reference(symbol_in_matcher), ]) source = arguments.as_remaining_source # ACT # actual = self.configuration.parser().parse(ARBITRARY_FS_LOCATION_INFO, source) actual_symbol_usages = actual.symbol_usages() # ASSERT # symbol_usages_assertion.apply_without_message(self, actual_symbol_usages)
def runTest(self): program_that_outputs_something = pgm_args.program( pgm_args.interpret_py_source_line( self.configuration.py_source_for_print('some output')), transformation=transformers_setup.DELETE_EVERYTHING_TRANSFORMER. name) result_when_positive = pfh_expectation_type_config( ExpectationType.POSITIVE) self._check_positive_and_negated( result_when_positive, program_that_outputs_something, matcher_arguments.emptiness_matcher(), lambda main_result: Expectation( main_result=main_result, symbol_usages=asrt.matches_sequence([ is_reference_to_string_transformer__usage( transformers_setup.DELETE_EVERYTHING_TRANSFORMER.name), ])), ArrangementPostAct(symbols=transformers_setup.SYMBOL_TABLE))
def test_check_non_zero_exit_code(self): self._check_single_line_arguments_with_source_variants( pgm_args.interpret_py_source_line('exit(1)').as_str, tcds_test.Arrangement(), tcds_test.Expectation(expected_action_result=result_assertions.equals(1, '')))
def _python_interpreter_for_source_on_command_line(argument: str) -> str: return pgm_args.interpret_py_source_line(argument).as_str
def test_check_non_zero_exit_code_with_output_to_stderr(self): python_program = 'import sys; sys.stderr.write("on stderr"); exit(2)' self._check_single_line_arguments_with_source_variants( pgm_args.interpret_py_source_line(python_program).as_str, tcds_test.Arrangement(), tcds_test.Expectation(expected_action_result=result_assertions.equals(2, 'on stderr')))