예제 #1
0
 def test_accessor_exception_from_accessor(self):
     # ARRANGE #
     process_error = tcp.ProcessError(
         error_info.of_exception(ValueError('exception message')))
     accessor = sut.AccessorFromParts(
         SourceReaderThat(raises(process_error)),
         PreprocessorThat(gives_constant('preprocessed source')),
         ParserThat(gives_constant(TEST_CASE)),
         identity_test_case_transformer())
     executor = ExecutorThat(raises(PROCESS_ERROR))
     processor = sut.ProcessorFromAccessorAndExecutor(accessor, executor)
     # ACT #
     result = processor.apply(tcp.test_case_reference_of_source_file(PATH))
     # ASSERT #
     self.assertIs(tcp.Status.ACCESS_ERROR, result.status)
     self.assertIs(tcp.AccessErrorType.FILE_ACCESS_ERROR,
                   result.access_error_type)
     self.assertIsNotNone(result.error_info, 'There should be ErrorInfo')
     err_description = result.error_info.description
     self.assertIsInstance(err_description,
                           error_description.ErrorDescriptionOfException)
     assert isinstance(err_description,
                       error_description.ErrorDescriptionOfException)
     self.assertEqual(err_description.exception.args[0],
                      'exception message')
예제 #2
0
 def test_implementation_exception_from_executor(self):
     # ARRANGE #
     accessor = sut.AccessorFromParts(
         SourceReaderThat(gives_constant('source')),
         PreprocessorThat(gives_constant('preprocessed source')),
         ParserThat(gives_constant(TEST_CASE)),
         identity_test_case_transformer())
     executor = ExecutorThat(raises(RuntimeError()))
     processor = sut.ProcessorFromAccessorAndExecutor(accessor, executor)
     # ACT #
     result = processor.apply(tcp.test_case_reference_of_source_file(PATH))
     # ASSERT #
     self.assertEqual(tcp.Status.INTERNAL_ERROR, result.status)
예제 #3
0
 def test_successful_application(self):
     # ARRANGE #
     accessor = sut.AccessorFromParts(
         SourceReaderThat(gives_constant('source')),
         PreprocessorThat(gives_constant('preprocessed source')),
         ParserThat(gives_constant(TEST_CASE)),
         identity_test_case_transformer())
     full_result = new_skipped()
     executor = ExecutorThatReturnsIfSame(TEST_CASE, full_result)
     processor = sut.ProcessorFromAccessorAndExecutor(accessor, executor)
     # ACT #
     result = processor.apply(tcp.test_case_reference_of_source_file(PATH))
     # ASSERT #
     self.assertIs(tcp.Status.EXECUTED, result.status)
     self.assertIs(full_result, result.execution_result)
예제 #4
0
    def _processor(
        self, settings: TestCaseExecutionSettings,
        result_reporter: result_reporting.TestCaseResultReporter
    ) -> processing.Processor:
        accessor_resolver = AccessorResolver(
            self._test_case_definition.parsing_setup,
            self._suite_configuration_section_parser,
            settings.handling_setup,
        )
        accessor, act_phase_setup = accessor_resolver.resolve(
            settings.test_case_file_path,
            settings.run_as_part_of_explicit_suite)

        executor = self._executor(
            act_phase_setup, result_reporter.depends_on_result_in_sandbox(),
            settings.sandbox_root_dir_resolver, result_reporter)

        return processing_utils.ProcessorFromAccessorAndExecutor(
            accessor, executor)
예제 #5
0
def new_processor_that_is_allowed_to_pollute_current_process(
        configuration: Configuration) -> processing.Processor:
    return processing_utils.ProcessorFromAccessorAndExecutor(
        new_accessor_from_conf(configuration),
        new_executor_that_may_pollute_current_processes(configuration))