コード例 #1
0
ファイル: model.py プロジェクト: imranc/TestAutomation-5.7
    def run(self, settings=None, **options):
        """Executes the suite based based the given ``settings`` or ``options``.

        :param settings: :class:`~robot.conf.settings.RobotSettings` object
            to configure test execution.
        :param options: Used to construct new
            :class:`~robot.conf.settings.RobotSettings` object if ``settings``
            are not given.
        :return: :class:`~robot.result.executionresult.Result` object with
            information about executed suites and tests.

        If ``options`` are used, their names are the same as long command line
        options except without hyphens, and they also have the same semantics.
        Options that can be given on the command line multiple times can be
        passed as lists like ``variable=['VAR1:value1', 'VAR2:value2']``.
        If such an option is used only once, it can be given also as a single
        string like ``variable='VAR:value'``.

        Only options related to the actual test execution have an effect.
        For example, options related to selecting test cases or creating
        logs and reports are silently ignored. The output XML generated
        as part of the execution can be configured, though, including
        disabling it with ``output=None``.

        Example::

            result = suite.run(variable='EXAMPLE:value',
                               critical='regression',
                               output='example.xml',
                               exitonfailure=True,
                               skipteardownonexit=True)
            print result.return_code

        To save memory, the returned
        :class:`~robot.result.executionresult.Result` object object does not
        have any information about the executed keywords. If that information
        is needed, the created output XML file needs to be read  using the
        :class:`~robot.result.resultbuilder.ExecutionResult` factory method.

        See the :mod:`package level <robot.running>` documentation for
        more examples, including how to construct executable test suites and
        how to create logs and reports based on the execution results.
        """
        STOP_SIGNAL_MONITOR.start()
        IMPORTER.reset()
        settings = settings or RobotSettings(options)
        pyloggingconf.initialize(settings['LogLevel'])
        init_global_variables(settings)
        output = Output(settings)
        runner = Runner(output, settings)
        self.visit(runner)
        output.close(runner.result)
        return runner.result
コード例 #2
0
    def __init__(self, name, BuiltIn=True, variable_getters=None):
        """Initialize with a `name`
           and optional additional variable lookup functions.

        - If a Variable is not found in the Robot's Variables dictionary,
          the `variable_getters` will be called in the given order
          with the Variable string in Robot syntax ($/@{...})
          until no `LookupError` or `DataError` is raised.
          (Used by the `robot_shell` to extend Variables lookup
           to IPython's `user_ns` and Python's `builtins`).

        :param BuiltIn: Import RFW's BuiltIn Library by default?
        :param variable_getters: A sequence of callables.
        """
        self.name = name
        self.debug = False
        try:
            GLOBAL_VARIABLES
        except NameError:
            # Robot 2.9+
            self._variables = VariableScopes(RobotSettings())
        else:
            # Robot 2.8
            if not GLOBAL_VARIABLES: # HACK
                init_global_variables(RobotSettings())
            self._variables = GLOBAL_VARIABLES.copy()
        # HACK even more to extend variable lookup
        self._variables.__class__ = variablesclass(
            self._variables.__class__, extra_getters=variable_getters)

        self._output = Output()
        self._context = Context(testrobot=self)
        self._suite = TestSuite(name)

        argspec = getargspec(Namespace.__init__)
        namespace = partial(
            Namespace, suite=self._suite, variables=self._variables)
        if 'resource' in argspec.args:
            # Robot 3.0
            self._namespace = namespace(resource=self._suite.resource)
        else:
            namespace.keywords.update(user_keywords=[], imports=None)
            if 'parent_variables' in argspec.args:
                # Robot 2.8
                self._namespace = namespace(parent_variables=None)
            else:
                # Robot 2.9
                self._namespace = namespace()

        if BuiltIn:
            self.Import('BuiltIn')
コード例 #3
0
ファイル: run.py プロジェクト: IlfirinPL/RIDE
 def main(self, datasources, **options):
     STOP_SIGNAL_MONITOR.start()
     settings = RobotSettings(options)
     pyloggingconf.initialize(settings['LogLevel'])
     LOGGER.register_console_logger(width=settings['MonitorWidth'],
                                    colors=settings['MonitorColors'],
                                    stdout=settings['StdOut'],
                                    stderr=settings['StdErr'])
     init_global_variables(settings)
     suite = TestSuite(datasources, settings)
     output = Output(settings)
     suite.run(output)
     LOGGER.info("Tests execution ended. Statistics:\n%s" % suite.get_stat_message())
     output.close(suite)
     if settings.is_rebot_needed():
         output, settings = settings.get_rebot_datasource_and_settings()
         ResultWriter(output).write_results(settings)
     return suite.return_code
コード例 #4
0
ファイル: model.py プロジェクト: Apaking/robotframework
    def run(self, settings=None, **options):
        """Executes the suite based based the given ``settings`` or ``options``.

        :param settings: :class:`~robot.conf.settings.RobotSettings` object
            to configure test execution.
        :param options: Used to construct new
            :class:`~robot.conf.settings.RobotSettings` object if ``settings``
            are not given.
        :return: :class:`~robot.result.executionresult.Result` object with
            information about executed suites and tests.

        If ``options`` are used, their names are the same as long command line
        options except without hyphens, and they also have the same semantics.
        Options that can be given on the command line multiple times can be
        passed as lists like ``variable=['VAR1:value1', 'VAR2:value2']``.
        If such an option is used only once, it can be given also as a single
        string like ``variable='VAR:value'``.

        To capture stdout and/or stderr streams, pass open file objects in as
        special keyword arguments `stdout` and `stderr`, respectively. Note
        that this works only in version 2.8.4 and newer.

        Only options related to the actual test execution have an effect.
        For example, options related to selecting test cases or creating
        logs and reports are silently ignored. The output XML generated
        as part of the execution can be configured, though. This includes
        disabling it with ``output=None``.

        Example::

            stdout = StringIO()
            result = suite.run(variable='EXAMPLE:value',
                               critical='regression',
                               output='example.xml',
                               exitonfailure=True,
                               stdout=stdout)
            print result.return_code

        To save memory, the returned
        :class:`~robot.result.executionresult.Result` object does not
        have any information about the executed keywords. If that information
        is needed, the created output XML file needs to be read  using the
        :class:`~robot.result.resultbuilder.ExecutionResult` factory method.

        See the :mod:`package level <robot.running>` documentation for
        more examples, including how to construct executable test suites and
        how to create logs and reports based on the execution results.

        See the :func:`robot.run <robot.run.run>` function for a higher-level
        API for executing tests in files or directories.
        """
        if not settings:
            settings = RobotSettings(options)
            LOGGER.register_console_logger(**settings.console_logger_config)
        with pyloggingconf.robot_handler_enabled(settings.log_level):
            with STOP_SIGNAL_MONITOR:
                IMPORTER.reset()
                init_global_variables(settings)
                output = Output(settings)
                runner = Runner(output, settings)
                self.visit(runner)
            output.close(runner.result)
        return runner.result
コード例 #5
0
ファイル: model.py プロジェクト: wejade/robotframework
    def run(self, settings=None, **options):
        """Executes the suite based based the given ``settings`` or ``options``.

        :param settings: :class:`~robot.conf.settings.RobotSettings` object
            to configure test execution.
        :param options: Used to construct new
            :class:`~robot.conf.settings.RobotSettings` object if ``settings``
            are not given.
        :return: :class:`~robot.result.executionresult.Result` object with
            information about executed suites and tests.

        If ``options`` are used, their names are the same as long command line
        options except without hyphens, and they also have the same semantics.
        Options that can be given on the command line multiple times can be
        passed as lists like ``variable=['VAR1:value1', 'VAR2:value2']``.
        If such an option is used only once, it can be given also as a single
        string like ``variable='VAR:value'``.

        To capture stdout and/or stderr streams, pass open file objects in as
        special keyword arguments `stdout` and `stderr`, respectively. Note
        that this works only in version 2.8.4 and newer.

        Only options related to the actual test execution have an effect.
        For example, options related to selecting test cases or creating
        logs and reports are silently ignored. The output XML generated
        as part of the execution can be configured, though. This includes
        disabling it with ``output=None``.

        Example::

            stdout = StringIO()
            result = suite.run(variable='EXAMPLE:value',
                               critical='regression',
                               output='example.xml',
                               exitonfailure=True,
                               stdout=stdout)
            print result.return_code

        To save memory, the returned
        :class:`~robot.result.executionresult.Result` object does not
        have any information about the executed keywords. If that information
        is needed, the created output XML file needs to be read  using the
        :class:`~robot.result.resultbuilder.ExecutionResult` factory method.

        See the :mod:`package level <robot.running>` documentation for
        more examples, including how to construct executable test suites and
        how to create logs and reports based on the execution results.

        See the :func:`robot.run <robot.run.run>` function for a higher-level
        API for executing tests in files or directories.
        """
        if not settings:
            settings = RobotSettings(options)
            LOGGER.register_console_logger(**settings.console_logger_config)
        with pyloggingconf.robot_handler_enabled(settings.log_level):
            with STOP_SIGNAL_MONITOR:
                IMPORTER.reset()
                init_global_variables(settings)
                output = Output(settings)
                runner = Runner(output, settings)
                self.visit(runner)
            output.close(runner.result)
        return runner.result
コード例 #6
0
            return False

    @classmethod
    def set_keywords_exposed(cls):
        cls._keywords_exposed = True
        
    @classmethod
    def set_cache(cls, cache):
        cls._cache = cache
        
    @classmethod
    def get_cache(cls):
        return cls._cache

    @classmethod
    def set_current_page(cls, name):
        BuiltIn().set_library_search_order(name)

    @classmethod
    def get_libraries(cls):
        return [lib.name for lib in EXECUTION_CONTEXTS.current.namespace.libraries]

# Set up Robot's global variables so we get all the built-in default settings when we're outside Robot.
# We need this for Selenium2Library's _get_log_dir() method, among other things.
# TODO: DCLT-693: Put this handling in some other place.
# TODO: DCLT-659: Write test, confirm we're not breaking anything inside Robot, and that we are
#  not preventing the setting of certain CL options. We shouldn't be, since we use _get_opts_no_robot() below,
#  and then fall back if needed to GLOBAL_VARIABLES, which will always have Robot's default values.
if not Context.in_robot():
    init_global_variables(RobotSettings())
コード例 #7
0
    @classmethod
    def set_cache(cls, cache):
        cls._cache = cache
        
    @classmethod
    def get_cache(cls):
        if cls._cache is None:
            try:
                cls._cache = cls.get_s2l_instance()._cache
            except:
                pass
        return cls._cache

    @classmethod
    def set_current_page(cls, name):
        BuiltIn().set_library_search_order(name)

    @classmethod
    def get_libraries(cls):
        return [lib.name for lib in EXECUTION_CONTEXTS.current.namespace.libraries]


# Set up Robot's global variables so we get all the built-in default settings when we're outside Robot.
# We need this for Selenium2Library's _get_log_dir() method, among other things.
# TODO: DCLT-693: Put this handling in some other place.
# TODO: DCLT-659: Write test, confirm we're not breaking anything inside Robot, and that we are
#  not preventing the setting of certain CL options. We shouldn't be, since we use _get_opts_no_robot() below,
#  and then fall back if needed to GLOBAL_VARIABLES, which will always have Robot's default values.
if not Context.in_robot():
    init_global_variables(RobotSettings())