robot.running.builder package

Submodules

robot.running.builder.builders module

class robot.running.builder.builders.TestSuiteBuilder(included_suites: str = 'DEPRECATED', included_extensions: Sequence[str] = ('.robot', '.rbt', '.robot.rst'), included_files: Sequence[str] = (), custom_parsers: Sequence[str] = (), defaults: TestDefaults | None = None, rpa: bool | None = None, lang: Languages | Language | str | Path | Iterable[Language | str | Path] | None = None, allow_empty_suite: bool = False, process_curdir: bool = True)[source]

Bases: object

Builder to construct TestSuite objects based on data on the disk.

The build() method constructs executable TestSuite objects based on test data files or directories. There are two main use cases for this API:

  • Execute the created suite by using its run() method. The suite can be modified before execution if needed.

  • Inspect the suite to see, for example, what tests it has or what tags tests have. This can be more convenient than using the lower level parsing APIs.

Both modifying the suite and inspecting what data it contains are easiest done by using the visitor interface.

This class is part of the public API and should be imported via the robot.api package. An alternative is using the TestSuite.from_file_system classmethod that uses this class internally.

Parameters:
  • included_suites – This argument used to be used for limiting what suite file to parse. It is deprecated and has no effect starting from RF 6.1. Use the new included_files argument or filter the created suite after parsing instead.

  • included_extensions – List of extensions of files to parse. Same as --extension.

  • included_files – List of names, paths or directory paths of files to parse. All files are parsed by default. Same as –parse-include. New in RF 6.1.

  • custom_parsers – Custom parsers as names or paths (same as --parser) or as parser objects. New in RF 6.1.

  • defaults – Possible test specific defaults from suite initialization files. New in RF 6.1.

  • rpa – Explicit execution mode. True for RPA and False for test automation. By default, mode is got from data file headers. Same as --rpa or --norpa.

  • lang – Additional languages to be supported during parsing. Can be a string matching any of the supported language codes or names, an initialized Language subclass, a list containing such strings or instances, or a Languages instance.

  • allow_empty_suite – Specify is it an error if the built suite contains no tests. Same as --runemptysuite.

  • process_curdir – Control processing the special ${CURDIR} variable. It is resolved already at parsing time by default, but that can be changed by giving this argument False value.

build(*paths: Path | str) TestSuite[source]
Parameters:

paths – Paths to test data files or directories.

Returns:

TestSuite instance.

class robot.running.builder.builders.SuiteStructureParser(parsers: dict[str | None, Parser], defaults: TestDefaults | None = None, rpa: bool | None = None)[source]

Bases: SuiteStructureVisitor

property parent_defaults: TestDefaults | None
parse(structure: SuiteStructure) TestSuite[source]
visit_file(structure: SuiteFile)[source]
start_directory(structure: SuiteDirectory)[source]
end_directory(structure: SuiteDirectory)[source]
class robot.running.builder.builders.ResourceFileBuilder(lang: Languages | Language | str | Path | Iterable[Language | str | Path] | None = None, process_curdir: bool = True)[source]

Bases: object

build(source: Path) ResourceFile[source]

robot.running.builder.parsers module

class robot.running.builder.parsers.Parser[source]

Bases: ABC

property name: str
parse_suite_file(source: Path, defaults: TestDefaults) TestSuite[source]
parse_init_file(source: Path, defaults: TestDefaults) TestSuite[source]
parse_resource_file(source: Path) ResourceFile[source]
class robot.running.builder.parsers.RobotParser(lang: Languages | Language | str | Path | Iterable[Language | str | Path] | None = None, process_curdir: bool = True)[source]

Bases: Parser

extensions = ()
parse_suite_file(source: Path, defaults: TestDefaults) TestSuite[source]
parse_init_file(source: Path, defaults: TestDefaults) TestSuite[source]
parse_model(model: File, defaults: TestDefaults | None = None) TestSuite[source]
parse_resource_file(source: Path) ResourceFile[source]
parse_resource_model(model: File) ResourceFile[source]
class robot.running.builder.parsers.RestParser(lang: Languages | Language | str | Path | Iterable[Language | str | Path] | None = None, process_curdir: bool = True)[source]

Bases: RobotParser

extensions = ('.robot.rst', '.rst', '.rest')
class robot.running.builder.parsers.JsonParser[source]

Bases: Parser

parse_suite_file(source: Path, defaults: TestDefaults) TestSuite[source]
parse_init_file(source: Path, defaults: TestDefaults) TestSuite[source]
parse_resource_file(source: Path) ResourceFile[source]
class robot.running.builder.parsers.NoInitFileDirectoryParser[source]

Bases: Parser

parse_init_file(source: Path, defaults: TestDefaults) TestSuite[source]
class robot.running.builder.parsers.CustomParser(parser)[source]

Bases: Parser

property name: str
property extensions: tuple[str, ...]
parse_suite_file(source: Path, defaults: TestDefaults) TestSuite[source]
parse_init_file(source: Path, defaults: TestDefaults) TestSuite[source]

robot.running.builder.settings module

class robot.running.builder.settings.OptionalItems[source]

Bases: TypedDict

args: Sequence[str]
lineno: int
class robot.running.builder.settings.FixtureDict[source]

Bases: OptionalItems

Dictionary containing setup or teardown info.

args and lineno are optional.

name: str
args: Sequence[str]
lineno: int
class robot.running.builder.settings.TestDefaults(parent: TestDefaults | None = None, setup: FixtureDict | None = None, teardown: FixtureDict | None = None, tags: Sequence[str] = (), timeout: str | None = None)[source]

Bases: object

Represents default values for test related settings set in init files.

Parsers parsing suite files can read defaults and parsers parsing init files can set them. The easiest way to set defaults to a test is using the set_to() method.

This class is part of the public parser API. When implementing parse or parse_init method so that they accept two arguments, the second is an instance of this class. If the class is needed as a type hint, it can be imported via robot.running or robot.api.interfaces.

property setup: FixtureDict | None

Default setup as a Keyword object or None when not set.

Can be set also using a dictionary.

property teardown: FixtureDict | None

Default teardown as a Keyword object or None when not set.

Can be set also using a dictionary.

property tags: tuple[str, ...]

Default tags. Can be set also as a sequence.

property timeout: str | None

Default timeout.

set_to(test: TestCase)[source]

Sets defaults to the given test.

Tags are always added to the test. Setup, teardown and timeout are set only if the test does not have them set initially.

class robot.running.builder.settings.FileSettings(test_defaults: TestDefaults | None = None)[source]

Bases: object

property test_setup: FixtureDict | None
property test_teardown: FixtureDict | None
property test_tags: tuple[str, ...]
property test_timeout: str | None
property test_template: str | None
property default_tags: tuple[str, ...]
property keyword_tags: tuple[str, ...]
class robot.running.builder.settings.InitFileSettings(test_defaults: TestDefaults | None = None)[source]

Bases: FileSettings

property test_setup: FixtureDict | None
property test_teardown: FixtureDict | None
property test_tags: tuple[str, ...]
property test_timeout: str | None

robot.running.builder.transformers module

class robot.running.builder.transformers.SettingsBuilder(suite: TestSuite, settings: FileSettings)[source]

Bases: ModelVisitor

visit_Documentation(node)[source]
visit_Metadata(node)[source]
visit_SuiteName(node)[source]
visit_SuiteSetup(node)[source]
visit_SuiteTeardown(node)[source]
visit_TestSetup(node)[source]
visit_TestTeardown(node)[source]
visit_TestTimeout(node)[source]
visit_DefaultTags(node)[source]
visit_TestTags(node)[source]
visit_KeywordTags(node)[source]
visit_TestTemplate(node)[source]
visit_LibraryImport(node)[source]
visit_ResourceImport(node)[source]
visit_VariablesImport(node)[source]
visit_VariableSection(node)[source]
visit_TestCaseSection(node)[source]
visit_KeywordSection(node)[source]
class robot.running.builder.transformers.SuiteBuilder(suite: TestSuite, settings: FileSettings)[source]

Bases: ModelVisitor

build(model: File)[source]
visit_SettingSection(node)[source]
visit_Variable(node)[source]
visit_TestCaseSection(node)[source]
visit_TestCase(node)[source]
visit_Keyword(node)[source]
class robot.running.builder.transformers.ResourceBuilder(resource: ResourceFile)[source]

Bases: ModelVisitor

build(model: File)[source]
visit_Documentation(node)[source]
visit_KeywordTags(node)[source]
visit_LibraryImport(node)[source]
visit_ResourceImport(node)[source]
visit_VariablesImport(node)[source]
visit_Variable(node)[source]
visit_Keyword(node)[source]
class robot.running.builder.transformers.BodyBuilder(model: TestCase | UserKeyword | For | If | Try | While | None = None)[source]

Bases: ModelVisitor

visit_For(node)[source]
visit_While(node)[source]
visit_If(node)[source]
visit_Try(node)[source]
visit_KeywordCall(node)[source]
visit_TemplateArguments(node)[source]
visit_Var(node)[source]
visit_Return(node)[source]
visit_Continue(node)[source]
visit_Break(node)[source]
visit_Error(node)[source]
class robot.running.builder.transformers.TestCaseBuilder(suite: TestSuite, settings: FileSettings)[source]

Bases: BodyBuilder

model: TestCase
build(node)[source]
visit_Documentation(node)[source]
visit_Setup(node)[source]
visit_Teardown(node)[source]
visit_Timeout(node)[source]
visit_Tags(node)[source]
visit_Template(node)[source]
class robot.running.builder.transformers.KeywordBuilder(resource: ResourceFile, settings: FileSettings, seen_keywords: NormalizedDict)[source]

Bases: BodyBuilder

model: UserKeyword
build(node)[source]
visit_Documentation(node)[source]
visit_Arguments(node)[source]
visit_Tags(node)[source]
visit_ReturnSetting(node)[source]
visit_Timeout(node)[source]
visit_Setup(node)[source]
visit_Teardown(node)[source]
visit_KeywordCall(node)[source]
class robot.running.builder.transformers.ForBuilder(parent: TestCase | UserKeyword | For | If | Try | While)[source]

Bases: BodyBuilder

model: For
build(node)[source]
class robot.running.builder.transformers.IfBuilder(parent: TestCase | UserKeyword | For | If | Try | While)[source]

Bases: BodyBuilder

model: IfBranch | None
build(node)[source]
class robot.running.builder.transformers.TryBuilder(parent: TestCase | UserKeyword | For | If | Try | While)[source]

Bases: BodyBuilder

model: TryBranch | None
build(node)[source]
visit_TemplateArguments(node)[source]
class robot.running.builder.transformers.WhileBuilder(parent: TestCase | UserKeyword | For | If | Try | While)[source]

Bases: BodyBuilder

model: While
build(node)[source]
robot.running.builder.transformers.format_error(errors)[source]
class robot.running.builder.transformers.ErrorReporter(source, raise_on_invalid_header=False)[source]

Bases: ModelVisitor

visit_TestCase(node)[source]
visit_Keyword(node)[source]
visit_ReturnSetting(node)[source]
visit_SectionHeader(node)[source]
visit_Error(node)[source]
report_error(source, error=None, warn=False, throw=False)[source]