Пример #1
0
        def run_test_case(*args, **kwargs):
            scope = command.current_scope
            try:
                with current_test_case.execution_context:
                    with self.running_test_cases.lock:
                        self.running_test_cases.append(current_test_case)
                    if self._abort:
                        raise SkipException('Skipped because run was aborted')
                    if current_test_case.disabled:
                        raise DisabledException(
                            current_test_case.disabled_message)
                    else:
                        result = self._exit_scopes(scope, current_test_case)
                        scope = result.scope
                        if not result.success:
                            e = self._handle_exit_scopes_fails(
                                current_test_case, result.exceptions)
                            raise SkipException(
                                'Skipping test case due to failures in preparation'
                            ) from e

                        scope = self._enter_scopes(scope, current_test_case)
                        logger.debug(
                            "Calling test case '{test}' with '{scope}'".format(
                                test=current_test_case.full_name,
                                scope=repr(scope)))

                        try:
                            extra_req = [
                                p.value for p in current_test_case.params
                                if p.is_req
                            ]
                            extra_kwargs = {
                                p.key: p.value
                                for p in current_test_case.params
                                if not p.is_req
                            }
                            kwargs.update(extra_kwargs)
                            self.component_factory.call(current_test_case.run,
                                                        scope,
                                                        *args,
                                                        extra_req=extra_req,
                                                        **kwargs)
                        finally:
                            result = self.component_factory.exit_scope(scope)
                            scope = result.scope
                            if not result.success:
                                self._handle_exit_scopes_fails(
                                    current_test_case, result.exceptions)

                        return RunResult(scope, None, None)
            except (Exception, TestCaseAborted) as e:
                try:
                    msg = str(traceback.format_exc())
                except Exception:
                    msg = str(e)
                return RunResult(scope, e, msg)
            finally:
                with self.running_test_cases.lock:
                    self.running_test_cases.remove(current_test_case)
Пример #2
0
def skip_if_docker_is_not_installed(exec, infra):
    if not infra.package('docker-ce').is_installed:
        raise SkipException('The docker-ce package is not installed')
    if not infra.service('docker').is_running:
        raise SkipException('The docker service is not running')
Пример #3
0
 def __init__(self):
     raise SkipException('init')
Пример #4
0
 def __exit__(self, exc_type, exc_val, exc_tb):
     raise SkipException('exit')
Пример #5
0
 def __enter__(self):
     raise SkipException('enter')
Пример #6
0
def test_skip():
    """Test that test cases can be skipped."""
    raise SkipException('Should be skipped')