Skip to content

robot.running.builder.settings

FixtureDict

Bases: OptionalItems

Dictionary containing setup or teardown info.

:attr:args and :attr:lineno are optional.

TestDefaults

1
2
3
4
5
6
7
TestDefaults(
    parent: TestDefaults | None = None,
    setup: FixtureDict | None = None,
    teardown: FixtureDict | None = None,
    tags: Sequence[str] = (),
    timeout: str | None = None,
)

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 :meth: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 :mod:robot.running or :mod:robot.api.interfaces.

__ http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#parser-interface

Source code in src/robot/running/builder/settings.py
def __init__(self, parent: 'TestDefaults|None' = None,
             setup: 'FixtureDict|None' = None,
             teardown: 'FixtureDict|None' = None,
             tags: 'Sequence[str]' = (), timeout: 'str|None' = None):
    self.parent = parent
    self.setup = setup
    self.teardown = teardown
    self.tags = tags
    self.timeout = timeout

setup property writable

setup: FixtureDict | None

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

Can be set also using a dictionary.

teardown property writable

teardown: FixtureDict | None

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

Can be set also using a dictionary.

tags property writable

tags: tuple[str, ...]

Default tags. Can be set also as a sequence.

timeout property writable

timeout: str | None

Default timeout.

set_to

set_to(test: TestCase)

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.

Source code in src/robot/running/builder/settings.py
def set_to(self, test: TestCase):
    """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.
    """
    if self.tags:
        test.tags += self.tags
    if self.setup and not test.has_setup:
        test.setup.config(**self.setup)
    if self.teardown and not test.has_teardown:
        test.teardown.config(**self.teardown)
    if self.timeout and not test.timeout:
        test.timeout = self.timeout