robot.parsing.model package

Submodules

robot.parsing.model.blocks module

class robot.parsing.model.blocks.Container[source]

Bases: Node, ABC

property lineno: int
property col_offset: int
property end_lineno: int
property end_col_offset: int
validate_model()[source]
validate(ctx: ValidationContext)[source]
class robot.parsing.model.blocks.File(sections: Sequence[Section] = (), source: Path | None = None, languages: Sequence[str] = ())[source]

Bases: Container

save(output: Path | str | TextIO | None = None)[source]

Save model to the given output or to the original source file.

The output can be a path to a file or an already opened file object. If output is not given, the original source file will be overwritten.

class robot.parsing.model.blocks.Block(header: Statement | None, body: Sequence[Statement | Block] = (), errors: Sequence[str] = ())[source]

Bases: Container, ABC

class robot.parsing.model.blocks.Section(header: Statement | None, body: Sequence[Statement | Block] = (), errors: Sequence[str] = ())[source]

Bases: Block

header: SectionHeader | None
class robot.parsing.model.blocks.SettingSection(header: Statement | None, body: Sequence[Statement | Block] = (), errors: Sequence[str] = ())[source]

Bases: Section

header: SectionHeader
class robot.parsing.model.blocks.VariableSection(header: Statement | None, body: Sequence[Statement | Block] = (), errors: Sequence[str] = ())[source]

Bases: Section

header: SectionHeader
class robot.parsing.model.blocks.TestCaseSection(header: Statement | None, body: Sequence[Statement | Block] = (), errors: Sequence[str] = ())[source]

Bases: Section

header: SectionHeader
property tasks: bool
class robot.parsing.model.blocks.KeywordSection(header: Statement | None, body: Sequence[Statement | Block] = (), errors: Sequence[str] = ())[source]

Bases: Section

header: SectionHeader
class robot.parsing.model.blocks.CommentSection(header: Statement | None, body: Sequence[Statement | Block] = (), errors: Sequence[str] = ())[source]

Bases: Section

header: SectionHeader | None
class robot.parsing.model.blocks.ImplicitCommentSection(header: Statement | None = None, body: Sequence[Statement | Block] = (), errors: Sequence[str] = ())[source]

Bases: CommentSection

header: None
class robot.parsing.model.blocks.InvalidSection(header: Statement | None, body: Sequence[Statement | Block] = (), errors: Sequence[str] = ())[source]

Bases: Section

class robot.parsing.model.blocks.TestCase(header: Statement | None, body: Sequence[Statement | Block] = (), errors: Sequence[str] = ())[source]

Bases: Block

header: TestCaseName
property name: str
validate(ctx: ValidationContext)[source]
class robot.parsing.model.blocks.Keyword(header: Statement | None, body: Sequence[Statement | Block] = (), errors: Sequence[str] = ())[source]

Bases: Block

header: KeywordName
property name: str
validate(ctx: ValidationContext)[source]
class robot.parsing.model.blocks.NestedBlock(header: Statement, body: Sequence[Statement | Block] = (), end: End | None = None, errors: Sequence[str] = ())[source]

Bases: Block

class robot.parsing.model.blocks.If(header: Statement, body: Sequence[Statement | Block] = (), orelse: If | None = None, end: End | None = None, errors: Sequence[str] = ())[source]

Bases: NestedBlock

Represents IF structures in the model.

Used with IF, Inline IF, ELSE IF and ELSE nodes. The type attribute specifies the type.

header: IfHeader | ElseIfHeader | ElseHeader
property type: str
property condition: str | None
property assign: tuple[str, ...]
validate(ctx: ValidationContext)[source]
class robot.parsing.model.blocks.For(header: Statement, body: Sequence[Statement | Block] = (), end: End | None = None, errors: Sequence[str] = ())[source]

Bases: NestedBlock

header: ForHeader
property assign: tuple[str, ...]
property variables: tuple[str, ...]
property values: tuple[str, ...]
property flavor: str | None
property start: str | None
property mode: str | None
property fill: str | None
validate(ctx: ValidationContext)[source]
class robot.parsing.model.blocks.Try(header: Statement, body: Sequence[Statement | Block] = (), next: Try | None = None, end: End | None = None, errors: Sequence[str] = ())[source]

Bases: NestedBlock

header: TryHeader | ExceptHeader | ElseHeader | FinallyHeader
property type: str
property patterns: tuple[str, ...]
property pattern_type: str | None
property assign: str | None
property variable: str | None
validate(ctx: ValidationContext)[source]
class robot.parsing.model.blocks.While(header: Statement, body: Sequence[Statement | Block] = (), end: End | None = None, errors: Sequence[str] = ())[source]

Bases: NestedBlock

header: WhileHeader
property condition: str
property limit: str | None
property on_limit: str | None
property on_limit_message: str | None
validate(ctx: ValidationContext)[source]
class robot.parsing.model.blocks.ModelWriter(output: Path | str | TextIO)[source]

Bases: ModelVisitor

write(model: Node)[source]
visit_Statement(statement: Statement)[source]
class robot.parsing.model.blocks.ModelValidator[source]

Bases: ModelVisitor

visit_Block(node: Block)[source]
visit_Statement(node: Statement)[source]
class robot.parsing.model.blocks.ValidationContext[source]

Bases: object

block(node: Block) Iterator[None][source]
property parent_block: Block | None
property tasks: bool
property in_keyword: bool
property in_loop: bool
property in_finally: bool
class robot.parsing.model.blocks.FirstStatementFinder[source]

Bases: ModelVisitor

classmethod find_from(model: Node) Statement | None[source]
visit_Statement(statement: Statement)[source]
generic_visit(node: Node)[source]

Called if no explicit visitor function exists for a node.

class robot.parsing.model.blocks.LastStatementFinder[source]

Bases: ModelVisitor

classmethod find_from(model: Node) Statement | None[source]
visit_Statement(statement: Statement)[source]

robot.parsing.model.statements module

class robot.parsing.model.statements.Node[source]

Bases: AST, ABC

lineno: int
col_offset: int
end_lineno: int
end_col_offset: int
errors: tuple[str, ...] = ()
class robot.parsing.model.statements.Statement(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: Node, ABC

type: str
handles_types: ClassVar[tuple[str, ...]] = ()
statement_handlers: ClassVar[dict[str, Type[Statement]]] = {'ARGUMENT': <class 'robot.parsing.model.statements.TemplateArguments'>, 'ARGUMENTS': <class 'robot.parsing.model.statements.Arguments'>, 'BREAK': <class 'robot.parsing.model.statements.Break'>, 'COMMENT': <class 'robot.parsing.model.statements.Comment'>, 'COMMENT HEADER': <class 'robot.parsing.model.statements.SectionHeader'>, 'CONFIG': <class 'robot.parsing.model.statements.Config'>, 'CONTINUE': <class 'robot.parsing.model.statements.Continue'>, 'DEFAULT TAGS': <class 'robot.parsing.model.statements.DefaultTags'>, 'DOCUMENTATION': <class 'robot.parsing.model.statements.Documentation'>, 'ELSE': <class 'robot.parsing.model.statements.ElseHeader'>, 'ELSE IF': <class 'robot.parsing.model.statements.ElseIfHeader'>, 'END': <class 'robot.parsing.model.statements.End'>, 'ERROR': <class 'robot.parsing.model.statements.Error'>, 'EXCEPT': <class 'robot.parsing.model.statements.ExceptHeader'>, 'FINALLY': <class 'robot.parsing.model.statements.FinallyHeader'>, 'FOR': <class 'robot.parsing.model.statements.ForHeader'>, 'IF': <class 'robot.parsing.model.statements.IfHeader'>, 'INLINE IF': <class 'robot.parsing.model.statements.InlineIfHeader'>, 'INVALID HEADER': <class 'robot.parsing.model.statements.SectionHeader'>, 'KEYWORD': <class 'robot.parsing.model.statements.KeywordCall'>, 'KEYWORD HEADER': <class 'robot.parsing.model.statements.SectionHeader'>, 'KEYWORD NAME': <class 'robot.parsing.model.statements.KeywordName'>, 'KEYWORD TAGS': <class 'robot.parsing.model.statements.KeywordTags'>, 'LIBRARY': <class 'robot.parsing.model.statements.LibraryImport'>, 'METADATA': <class 'robot.parsing.model.statements.Metadata'>, 'RESOURCE': <class 'robot.parsing.model.statements.ResourceImport'>, 'RETURN': <class 'robot.parsing.model.statements.ReturnSetting'>, 'RETURN STATEMENT': <class 'robot.parsing.model.statements.Return'>, 'SETTING HEADER': <class 'robot.parsing.model.statements.SectionHeader'>, 'SETUP': <class 'robot.parsing.model.statements.Setup'>, 'SUITE NAME': <class 'robot.parsing.model.statements.SuiteName'>, 'SUITE SETUP': <class 'robot.parsing.model.statements.SuiteSetup'>, 'SUITE TEARDOWN': <class 'robot.parsing.model.statements.SuiteTeardown'>, 'TAGS': <class 'robot.parsing.model.statements.Tags'>, 'TASK HEADER': <class 'robot.parsing.model.statements.SectionHeader'>, 'TEARDOWN': <class 'robot.parsing.model.statements.Teardown'>, 'TEMPLATE': <class 'robot.parsing.model.statements.Template'>, 'TEST SETUP': <class 'robot.parsing.model.statements.TestSetup'>, 'TEST TAGS': <class 'robot.parsing.model.statements.TestTags'>, 'TEST TEARDOWN': <class 'robot.parsing.model.statements.TestTeardown'>, 'TEST TEMPLATE': <class 'robot.parsing.model.statements.TestTemplate'>, 'TEST TIMEOUT': <class 'robot.parsing.model.statements.TestTimeout'>, 'TESTCASE HEADER': <class 'robot.parsing.model.statements.SectionHeader'>, 'TESTCASE NAME': <class 'robot.parsing.model.statements.TestCaseName'>, 'TIMEOUT': <class 'robot.parsing.model.statements.Timeout'>, 'TRY': <class 'robot.parsing.model.statements.TryHeader'>, 'VAR': <class 'robot.parsing.model.statements.Var'>, 'VARIABLE': <class 'robot.parsing.model.statements.Variable'>, 'VARIABLE HEADER': <class 'robot.parsing.model.statements.SectionHeader'>, 'VARIABLES': <class 'robot.parsing.model.statements.VariablesImport'>, 'WHILE': <class 'robot.parsing.model.statements.WhileHeader'>}
options: dict[str, tuple | None] = {}
property lineno: int
property col_offset: int
property end_lineno: int
property end_col_offset: int
classmethod register(subcls: Type[T]) Type[T][source]

Register a virtual subclass of an ABC.

Returns the subclass, to allow usage as a class decorator.

classmethod from_tokens(tokens: Sequence[Token]) Statement[source]

Create a statement from given tokens.

Statement type is got automatically from token types.

This classmethod should be called from Statement, not from its subclasses. If you know the subclass to use, simply create an instance of it directly.

abstract classmethod from_params(*args, **kwargs) Statement[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

property data_tokens: list[Token]
get_token(*types: str) Token | None[source]

Return a token with any of the given types.

If there are no matches, return None. If there are multiple matches, return the first match.

get_tokens(*types: str) list[Token][source]

Return tokens having any of the given types.

get_value(type: str, default: str) str[source]
get_value(type: str, default: None = None) str | None

Return value of a token with the given type.

If there are no matches, return default. If there are multiple matches, return the value of the first match.

get_values(*types: str) tuple[str, ...][source]

Return values of tokens having any of the given types.

get_option(name: str, default: str | None = None) str | None[source]

Return value of a configuration option with the given name.

If the option has not been used, return default.

If the option has been used multiple times, values are joined together. This is typically an error situation and validated elsewhere.

New in Robot Framework 6.1.

property lines: Iterator[list[Token]]
validate(ctx: ValidationContext)[source]
class robot.parsing.model.statements.DocumentationOrMetadata(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: Statement, ABC

property value: str
class robot.parsing.model.statements.SingleValue(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: Statement, ABC

property value: str | None
class robot.parsing.model.statements.MultiValue(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: Statement, ABC

property values: tuple[str, ...]
class robot.parsing.model.statements.Fixture(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: Statement, ABC

property name: str
property args: tuple[str, ...]
class robot.parsing.model.statements.SectionHeader(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: Statement

handles_types: ClassVar[tuple[str, ...]] = ('SETTING HEADER', 'VARIABLE HEADER', 'TESTCASE HEADER', 'TASK HEADER', 'KEYWORD HEADER', 'COMMENT HEADER', 'INVALID HEADER')
classmethod from_params(type: str, name: str | None = None, eol: str = '\n') SectionHeader[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

property type: str
property name: str
class robot.parsing.model.statements.LibraryImport(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: Statement

type: str = 'LIBRARY'
classmethod from_params(name: str, args: Sequence[str] = (), alias: str | None = None, separator: str = '    ', eol: str = '\n') LibraryImport[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

property name: str
property args: tuple[str, ...]
property alias: str | None
class robot.parsing.model.statements.ResourceImport(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: Statement

type: str = 'RESOURCE'
classmethod from_params(name: str, separator: str = '    ', eol: str = '\n') ResourceImport[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

property name: str
class robot.parsing.model.statements.VariablesImport(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: Statement

type: str = 'VARIABLES'
classmethod from_params(name: str, args: Sequence[str] = (), separator: str = '    ', eol: str = '\n') VariablesImport[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

property name: str
property args: tuple[str, ...]
class robot.parsing.model.statements.Documentation(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: DocumentationOrMetadata

type: str = 'DOCUMENTATION'
classmethod from_params(value: str, indent: str = '    ', separator: str = '    ', eol: str = '\n', settings_section: bool = True) Documentation[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

class robot.parsing.model.statements.Metadata(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: DocumentationOrMetadata

type: str = 'METADATA'
classmethod from_params(name: str, value: str, separator: str = '    ', eol: str = '\n') Metadata[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

property name: str
class robot.parsing.model.statements.TestTags(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: MultiValue

type: str = 'TEST TAGS'
classmethod from_params(values: Sequence[str], separator: str = '    ', eol: str = '\n') TestTags[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

class robot.parsing.model.statements.DefaultTags(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: MultiValue

type: str = 'DEFAULT TAGS'
classmethod from_params(values: Sequence[str], separator: str = '    ', eol: str = '\n') DefaultTags[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

class robot.parsing.model.statements.KeywordTags(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: MultiValue

type: str = 'KEYWORD TAGS'
classmethod from_params(values: Sequence[str], separator: str = '    ', eol: str = '\n') KeywordTags[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

class robot.parsing.model.statements.SuiteName(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: SingleValue

type: str = 'SUITE NAME'
classmethod from_params(value: str, separator: str = '    ', eol: str = '\n') SuiteName[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

class robot.parsing.model.statements.SuiteSetup(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: Fixture

type: str = 'SUITE SETUP'
classmethod from_params(name: str, args: Sequence[str] = (), separator: str = '    ', eol: str = '\n') SuiteSetup[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

class robot.parsing.model.statements.SuiteTeardown(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: Fixture

type: str = 'SUITE TEARDOWN'
classmethod from_params(name: str, args: Sequence[str] = (), separator: str = '    ', eol: str = '\n') SuiteTeardown[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

class robot.parsing.model.statements.TestSetup(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: Fixture

type: str = 'TEST SETUP'
classmethod from_params(name: str, args: Sequence[str] = (), separator: str = '    ', eol: str = '\n') TestSetup[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

class robot.parsing.model.statements.TestTeardown(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: Fixture

type: str = 'TEST TEARDOWN'
classmethod from_params(name: str, args: Sequence[str] = (), separator: str = '    ', eol: str = '\n') TestTeardown[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

class robot.parsing.model.statements.TestTemplate(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: SingleValue

type: str = 'TEST TEMPLATE'
classmethod from_params(value: str, separator: str = '    ', eol: str = '\n') TestTemplate[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

class robot.parsing.model.statements.TestTimeout(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: SingleValue

type: str = 'TEST TIMEOUT'
classmethod from_params(value: str, separator: str = '    ', eol: str = '\n') TestTimeout[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

class robot.parsing.model.statements.Variable(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: Statement

type: str = 'VARIABLE'
options: dict[str, tuple | None] = {'separator': None}
classmethod from_params(name: str, value: str | Sequence[str], value_separator: str | None = None, separator: str = '    ', eol: str = '\n') Variable[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

property name: str
property value: tuple[str, ...]
property separator: str | None
validate(ctx: ValidationContext)[source]
class robot.parsing.model.statements.TestCaseName(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: Statement

type: str = 'TESTCASE NAME'
classmethod from_params(name: str, eol: str = '\n') TestCaseName[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

property name: str
validate(ctx: ValidationContext)[source]
class robot.parsing.model.statements.KeywordName(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: Statement

type: str = 'KEYWORD NAME'
classmethod from_params(name: str, eol: str = '\n') KeywordName[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

property name: str
validate(ctx: ValidationContext)[source]
class robot.parsing.model.statements.Setup(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: Fixture

type: str = 'SETUP'
classmethod from_params(name: str, args: Sequence[str] = (), indent: str = '    ', separator: str = '    ', eol: str = '\n') Setup[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

class robot.parsing.model.statements.Teardown(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: Fixture

type: str = 'TEARDOWN'
classmethod from_params(name: str, args: Sequence[str] = (), indent: str = '    ', separator: str = '    ', eol: str = '\n') Teardown[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

class robot.parsing.model.statements.Tags(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: MultiValue

type: str = 'TAGS'
classmethod from_params(values: Sequence[str], indent: str = '    ', separator: str = '    ', eol: str = '\n') Tags[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

class robot.parsing.model.statements.Template(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: SingleValue

type: str = 'TEMPLATE'
classmethod from_params(value: str, indent: str = '    ', separator: str = '    ', eol: str = '\n') Template[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

class robot.parsing.model.statements.Timeout(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: SingleValue

type: str = 'TIMEOUT'
classmethod from_params(value: str, indent: str = '    ', separator: str = '    ', eol: str = '\n') Timeout[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

class robot.parsing.model.statements.Arguments(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: MultiValue

type: str = 'ARGUMENTS'
classmethod from_params(args: Sequence[str], indent: str = '    ', separator: str = '    ', eol: str = '\n') Arguments[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

validate(ctx: ValidationContext)[source]
class robot.parsing.model.statements.ReturnSetting(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: MultiValue

Represents the deprecated [Return] setting.

This class was named Return prior to Robot Framework 7.0. A forward compatible ReturnSetting alias existed already in Robot Framework 6.1.

type: str = 'RETURN'
classmethod from_params(args: Sequence[str], indent: str = '    ', separator: str = '    ', eol: str = '\n') ReturnSetting[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

class robot.parsing.model.statements.KeywordCall(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: Statement

type: str = 'KEYWORD'
classmethod from_params(name: str, assign: Sequence[str] = (), args: Sequence[str] = (), indent: str = '    ', separator: str = '    ', eol: str = '\n') KeywordCall[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

property keyword: str
property args: tuple[str, ...]
property assign: tuple[str, ...]
class robot.parsing.model.statements.TemplateArguments(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: Statement

type: str = 'ARGUMENT'
classmethod from_params(args: Sequence[str], indent: str = '    ', separator: str = '    ', eol: str = '\n') TemplateArguments[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

property args: tuple[str, ...]
class robot.parsing.model.statements.ForHeader(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: Statement

type: str = 'FOR'
options: dict[str, tuple | None] = {'fill': None, 'mode': ('STRICT', 'SHORTEST', 'LONGEST'), 'start': None}
classmethod from_params(assign: Sequence[str], values: Sequence[str], flavor: Literal['IN', 'IN RANGE', 'IN ENUMERATE', 'IN ZIP'] = 'IN', indent: str = '    ', separator: str = '    ', eol: str = '\n') ForHeader[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

property assign: tuple[str, ...]
property variables: tuple[str, ...]
property values: tuple[str, ...]
property flavor: str | None
property start: str | None
property mode: str | None
property fill: str | None
validate(ctx: ValidationContext)[source]
class robot.parsing.model.statements.IfElseHeader(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: Statement, ABC

property condition: str | None
property assign: tuple[str, ...]
validate(ctx: ValidationContext)[source]
class robot.parsing.model.statements.IfHeader(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: IfElseHeader

type: str = 'IF'
classmethod from_params(condition: str, indent: str = '    ', separator: str = '    ', eol: str = '\n') IfHeader[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

class robot.parsing.model.statements.InlineIfHeader(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: IfElseHeader

type: str = 'INLINE IF'
classmethod from_params(condition: str, assign: Sequence[str] = (), indent: str = '    ', separator: str = '    ') InlineIfHeader[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

class robot.parsing.model.statements.ElseIfHeader(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: IfElseHeader

type: str = 'ELSE IF'
classmethod from_params(condition: str, indent: str = '    ', separator: str = '    ', eol: str = '\n') ElseIfHeader[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

class robot.parsing.model.statements.ElseHeader(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: IfElseHeader

type: str = 'ELSE'
classmethod from_params(indent: str = '    ', eol: str = '\n') ElseHeader[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

validate(ctx: ValidationContext)[source]
class robot.parsing.model.statements.NoArgumentHeader(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: Statement, ABC

classmethod from_params(indent: str = '    ', eol: str = '\n')[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

validate(ctx: ValidationContext)[source]
property values: tuple[str, ...]
class robot.parsing.model.statements.TryHeader(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: NoArgumentHeader

type: str = 'TRY'
class robot.parsing.model.statements.ExceptHeader(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: Statement

type: str = 'EXCEPT'
options: dict[str, tuple | None] = {'type': ('GLOB', 'REGEXP', 'START', 'LITERAL')}
classmethod from_params(patterns: Sequence[str] = (), type: str | None = None, assign: str | None = None, indent: str = '    ', separator: str = '    ', eol: str = '\n') ExceptHeader[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

property patterns: tuple[str, ...]
property pattern_type: str | None
property assign: str | None
property variable: str | None
validate(ctx: ValidationContext)[source]
class robot.parsing.model.statements.FinallyHeader(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: NoArgumentHeader

type: str = 'FINALLY'
class robot.parsing.model.statements.End(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: NoArgumentHeader

type: str = 'END'
class robot.parsing.model.statements.WhileHeader(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: Statement

type: str = 'WHILE'
options: dict[str, tuple | None] = {'limit': None, 'on_limit': ('PASS', 'FAIL'), 'on_limit_message': None}
classmethod from_params(condition: str, limit: str | None = None, on_limit: str | None = None, on_limit_message: str | None = None, indent: str = '    ', separator: str = '    ', eol: str = '\n') WhileHeader[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

property condition: str
property limit: str | None
property on_limit: str | None
property on_limit_message: str | None
validate(ctx: ValidationContext)[source]
class robot.parsing.model.statements.Var(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: Statement

type: str = 'VAR'
options: dict[str, tuple | None] = {'scope': ('GLOBAL', 'SUITE', 'TEST', 'TASK', 'LOCAL'), 'separator': None}
classmethod from_params(name: str, value: str | Sequence[str], scope: str | None = None, value_separator: str | None = None, indent: str = '    ', separator: str = '    ', eol: str = '\n') Var[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

property name: str
property value: tuple[str, ...]
property scope: str | None
property separator: str | None
validate(ctx: ValidationContext)[source]
class robot.parsing.model.statements.Return(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: Statement

Represents the RETURN statement.

This class named ReturnStatement prior to Robot Framework 7.0. The old name still exists as a backwards compatible alias.

type: str = 'RETURN STATEMENT'
classmethod from_params(values: Sequence[str] = (), indent: str = '    ', separator: str = '    ', eol: str = '\n') Return[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

property values: tuple[str, ...]
validate(ctx: ValidationContext)[source]
robot.parsing.model.statements.ReturnStatement

alias of Return

class robot.parsing.model.statements.LoopControl(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: NoArgumentHeader, ABC

validate(ctx: ValidationContext)[source]
class robot.parsing.model.statements.Continue(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: LoopControl

type: str = 'CONTINUE'
class robot.parsing.model.statements.Break(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: LoopControl

type: str = 'BREAK'
class robot.parsing.model.statements.Comment(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: Statement

type: str = 'COMMENT'
classmethod from_params(comment: str, indent: str = '    ', eol: str = '\n') Comment[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

class robot.parsing.model.statements.Config(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: Statement

type: str = 'CONFIG'
classmethod from_params(config: str, eol: str = '\n') Config[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

property language: Language | None
class robot.parsing.model.statements.Error(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: Statement

type: str = 'ERROR'
classmethod from_params(error: str, value: str = '', indent: str = '    ', eol: str = '\n') Error[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

property values: list[str]
property errors: tuple[str, ...]

Errors got from the underlying ``ERROR``token.

Errors can be set also explicitly. When accessing errors, they are returned along with errors got from tokens.

class robot.parsing.model.statements.EmptyLine(tokens: Sequence[Token], errors: Sequence[str] = ())[source]

Bases: Statement

type: str = 'EOL'
classmethod from_params(eol: str = '\n')[source]

Create a statement from passed parameters.

Required and optional arguments in general match class properties. Values are used to create matching tokens.

Most implementations support following general properties:

  • separator whitespace inserted between each token. Default is four spaces.

  • indent whitespace inserted before first token. Default is four spaces.

  • eol end of line sign. Default is '\n'.

This classmethod should be called from the Statement subclass to create, not from the Statement class itself.

class robot.parsing.model.statements.VariableValidator[source]

Bases: object

validate(statement: Statement)[source]

robot.parsing.model.visitor module

class robot.parsing.model.visitor.VisitorFinder[source]

Bases: object

generic_visit(node: Node) None | Node | list[Node][source]
class robot.parsing.model.visitor.ModelVisitor[source]

Bases: NodeVisitor, VisitorFinder

NodeVisitor that supports matching nodes based on their base classes.

The biggest difference compared to the standard ast.NodeVisitor, is that this class allows creating visit_ClassName methods so that the ClassName is one of the base classes of the node. For example, the following visitor method matches all node classes that extend Statement:

def visit_Statement(self, node):
    ...

Another difference is that visitor methods are cached for performance reasons. This means that dynamically adding visit_Something methods does not work.

visit(node: Node) None[source]

Visit a node.

class robot.parsing.model.visitor.ModelTransformer[source]

Bases: NodeTransformer, VisitorFinder

NodeTransformer that supports matching nodes based on their base classes.

See ModelVisitor for explanation how this is different compared to the standard ast.NodeTransformer.

visit(node: Node) None | Node | list[Node][source]

Visit a node.