38 from robot
import model
40 from robot.errors import BreakLoop, ContinueLoop, ReturnFromKeyword, DataError
43 from robot.result import (Break
as BreakResult, Continue
as ContinueResult,
44 Return
as ReturnResult)
47 from .bodyrunner
import ForRunner, IfRunner, KeywordRunner, TryRunner, WhileRunner
48 from .randomizer
import Randomizer
49 from .statusreporter
import StatusReporter
65 __slots__ = [
'lineno']
67 def __init__(self, name='', doc='', args=(), assign=(), tags=(), timeout=
None,
68 type=BodyItem.KEYWORD, parent=
None, lineno=
None):
69 super().
__init__(name, doc, args, assign, tags, timeout, type, parent)
76 return self.
parentparent.source
if self.
parentparent
is not None else None
78 def run(self, context, run=True, templated=None):
84 __slots__ = [
'lineno',
'error']
87 def __init__(self, variables, flavor, values, parent=None, lineno=None, error=None):
88 super().
__init__(variables, flavor, values, parent)
96 return self.
parentparent.source
if self.
parentparent
is not None else None
98 def run(self, context, run=True, templated=False):
104 __slots__ = [
'lineno',
'error']
107 def __init__(self, condition=None, limit=None, parent=None, lineno=None, error=None):
108 super().
__init__(condition, limit, parent)
116 return self.
parentparent.source
if self.
parentparent
is not None else None
118 def run(self, context, run=True, templated=False):
123 __slots__ = [
'lineno']
126 def __init__(self, type=BodyItem.IF, condition=None, parent=None, lineno=None):
127 super().
__init__(type, condition, parent)
134 return self.
parentparent.source
if self.
parentparent
is not None else None
139 __slots__ = [
'lineno',
'error']
140 branch_class = IfBranch
142 def __init__(self, parent=None, lineno=None, error=None):
151 return self.
parentparent.source
if self.
parentparent
is not None else None
153 def run(self, context, run=True, templated=False):
158 __slots__ = [
'lineno']
161 def __init__(self, type=BodyItem.TRY, patterns=(), pattern_type=
None,
162 variable=
None, parent=
None, lineno=
None):
163 super().
__init__(type, patterns, pattern_type, variable, parent)
170 return self.
parentparent.source
if self.
parentparent
is not None else None
175 __slots__ = [
'lineno',
'error']
176 branch_class = TryBranch
178 def __init__(self, parent=None, lineno=None, error=None):
187 return self.
parentparent.source
if self.
parentparent
is not None else None
189 def run(self, context, run=True, templated=False):
195 __slots__ = [
'lineno',
'error']
197 def __init__(self, values=(), parent=
None, lineno=
None, error=
None):
206 return self.
parentparent.source
if self.
parentparent
is not None else None
208 def run(self, context, run=True, templated=False):
213 if not context.dry_run:
219 __slots__ = [
'lineno',
'error']
221 def __init__(self, parent=None, lineno=None, error=None):
230 return self.
parentparent.source
if self.
parentparent
is not None else None
232 def run(self, context, run=True, templated=False):
237 if not context.dry_run:
243 __slots__ = [
'lineno',
'error']
245 def __init__(self, parent=None, lineno=None, error=None):
254 return self.
parentparent.source
if self.
parentparent
is not None else None
256 def run(self, context, run=True, templated=False):
261 if not context.dry_run:
270 __slots__ = [
'template']
272 fixture_class = Keyword
274 def __init__(self, name='', doc='', tags=None, timeout=None, template=None,
276 super().
__init__(name, doc, tags, timeout, lineno)
285 return self.
parentparent.source
if self.
parentparent
is not None else None
293 __slots__ = [
'resource']
294 test_class = TestCase
295 fixture_class = Keyword
297 def __init__(self, name='', doc='', metadata=None, source=None, rpa=None):
298 super().
__init__(name, doc, metadata, source, rpa)
315 from .builder
import TestSuiteBuilder
316 return TestSuiteBuilder(**config).build(*paths)
328 from .builder
import RobotParser
329 return RobotParser().build_suite(model, name)
349 def configure(self, randomize_suites=False, randomize_tests=False,
350 randomize_seed=None, **options):
351 model.TestSuite.configure(self, **options)
352 self.
randomizerandomize(randomize_suites, randomize_tests, randomize_seed)
361 def randomize(self, suites=True, tests=True, seed=None):
417 def run(self, settings=None, **options):
418 from .namespace
import IMPORTER
419 from .signalhandler
import STOP_SIGNAL_MONITOR
420 from .suiterunner
import SuiteRunner
425 LOGGER.register_console_logger(**settings.console_output_config)
426 with pyloggingconf.robot_handler_enabled(settings.log_level):
427 with STOP_SIGNAL_MONITOR:
430 runner = SuiteRunner(output, settings)
431 self.
visitvisit(runner)
432 output.close(runner.result)
438 def __init__(self, name, value, source=None, lineno=None, error=None):
446 source = self.
sourcesource
or '<unknown>'
447 line = f
' on line {self.lineno}' if self.
linenolineno
else ''
448 LOGGER.write(f
"Error in file '{source}'{line}: "
449 f
"Setting variable '{self.name}' failed: {message}", level)
467 return model.ItemList(UserKeyword, {
'parent': self}, items=keywords)
476 def __init__(self, name, args=(), doc=
'', tags=(), return_=
None,
477 timeout=
None, lineno=
None, parent=
None, error=
None):
493 return Body(self, body)
511 Keywords.raise_deprecation_error()
529 return self.
parentparent.source
if self.
parentparent
is not None else None
533 ALLOWED_TYPES = (
'Library',
'Resource',
'Variables')
535 def __init__(self, type, name, args=(), alias=
None, source=
None, lineno=
None):
537 raise ValueError(f
"Invalid import type '{type}'. Should be one of "
538 f
"{seq2str(self.ALLOWED_TYPES, lastsep=' or ')}.")
552 if os.path.isdir(self.
sourcesource):
554 return os.path.dirname(self.
sourcesource)
557 source = self.
sourcesource
or '<unknown>'
558 line = f
' on line {self.lineno}' if self.
linenolineno
else ''
559 LOGGER.write(f
"Error in file '{source}'{line}: {message}", level)
565 super().
__init__(Import, {
'source': source}, items=imports)
567 def library(self, name, args=(), alias=
None, lineno=
None):
568 self.
createcreate(
'Library', name, args, alias, lineno)
571 self.
createcreate(
'Resource', path, lineno)
574 self.
createcreate(
'Variables', path, args, lineno)
Used by CONTINUE statement.
Used by 'RETURN' statement.
def create(self, *args, **kwargs)
A list-like object representing keywords in a suite, a test or a keyword.
def visit(self, visitor)
:mod:Visitor interface <robot.model.visitor> entry-point.
def __init__(self, status='FAIL', starttime=None, endtime=None, parent=None)
def __init__(self, status='FAIL', starttime=None, endtime=None, parent=None)
def __init__(self, values=(), status='FAIL', starttime=None, endtime=None, parent=None)
def __init__(self, variables, flavor, values, parent=None, lineno=None, error=None)
def run(self, context, run=True, templated=False)
def __init__(self, type=BodyItem.IF, condition=None, parent=None, lineno=None)
def __init__(self, parent=None, lineno=None, error=None)
def run(self, context, run=True, templated=False)
def __init__(self, type, name, args=(), alias=None, source=None, lineno=None)
def report_invalid_syntax(self, message, level='ERROR')
def __init__(self, source, imports=None)
def resource(self, path, lineno=None)
def variables(self, path, args=(), lineno=None)
def library(self, name, args=(), alias=None, lineno=None)
Represents a single executable keyword.
def run(self, context, run=True, templated=None)
def __init__(self, name='', doc='', args=(), assign=(), tags=(), timeout=None, type=BodyItem.KEYWORD, parent=None, lineno=None)
def __init__(self, doc='', source=None)
def imports(self, imports)
def keywords(self, keywords)
def variables(self, variables)
Represents a single executable test case.
def __init__(self, name='', doc='', tags=None, timeout=None, template=None, lineno=None)
Represents a single executable test suite.
def configure(self, randomize_suites=False, randomize_tests=False, randomize_seed=None, **options)
A shortcut to configure a suite using one method call.
def __init__(self, name='', doc='', metadata=None, source=None, rpa=None)
def run(self, settings=None, **options)
Executes the suite based based the given settings or options.
def from_file_system(cls, *paths, **config)
Create a :class:TestSuite object based on the given paths.
def from_model(cls, model, name=None)
Create a :class:TestSuite object based on the given model.
def randomize(self, suites=True, tests=True, seed=None)
Randomizes the order of suites and/or tests, recursively.
def __init__(self, type=BodyItem.TRY, patterns=(), pattern_type=None, variable=None, parent=None, lineno=None)
def __init__(self, parent=None, lineno=None, error=None)
def run(self, context, run=True, templated=False)
def body(self, body)
Child keywords as a :class:~.Body object.
def __init__(self, name, args=(), doc='', tags=(), return_=None, timeout=None, lineno=None, parent=None, error=None)
keywords
Deprecated since Robot Framework 4.0.
def report_invalid_syntax(self, message, level='ERROR')
def __init__(self, name, value, source=None, lineno=None, error=None)
def run(self, context, run=True, templated=False)
def __init__(self, condition=None, limit=None, parent=None, lineno=None, error=None)
def run(*tests, **options)
Programmatic entry point for running tests.
def ForRunner(context, flavor='IN', run=True, templated=False)