Skip to content

robot.running.testlibraries

TestLibrary

1
2
3
4
5
6
7
8
TestLibrary(
    code: type | ModuleType,
    init: LibraryInit,
    name: str | None = None,
    real_name: str | None = None,
    source: Path | None = None,
    logger=LOGGER,
)

Represents imported test library.

Source code in src/robot/running/testlibraries.py
def __init__(self, code: 'type|ModuleType',
             init: LibraryInit,
             name: 'str|None' = None,
             real_name: 'str|None' = None,
             source: 'Path|None' = None,
             logger=LOGGER):
    self.code = code
    self.init = init
    self.init.owner = self
    self.instance = None
    self.name = name or code.__name__
    self.real_name = real_name or self.name
    self.source = source
    self._logger = logger
    self.keywords: list[LibraryKeyword] = []
    self._has_listeners = None
    self.scope_manager = ScopeManager.for_library(self)
    self.keyword_finder = KeywordFinder[LibraryKeyword](self)

instance property writable

instance: Any

Current library instance.

With module based libraries this is the module itself.

With class based libraries this is an instance of the class. Instances are cleared automatically during execution based on their scope. Accessing this property creates a new instance if needed.

:attr:code´ contains the original library code. With module based libraries it is the same as :attr:instance`. With class based libraries it is the library class.