Dynamic libraries and PythonLibCore

Hello,
I try to use PythonLibCore together with the Robot Framework dynamic library API, but the so build library does not return any keywords.

Did anyone used PythonLibCore together with the dynamic library api or know how to use it?

Here is an short example (does not contains required imports):
dynamic_lib.py

from robot.api.deco import library
from robotlibcore import DynamicCore

from DynamicLib.lib_a import LibA

@library
class DynamicLib(DynamicCore):

    def __init__(self):
        DynamicCore.__init__(self, [LibA()])

lib_a.py

from typing import Any, List, Dict

from robot.api.deco import library
from robot.api.interfaces import DynamicLibrary


@library
class LibA(DynamicLibrary):  # DynamicLibrary: abstract baseclass for interface

    def get_keyword_names(self) -> List[str]:
        return ['A Keyword 1', 'A Keyword 2']

    def run_keyword(self, name: str, args: List[Any], named: Dict[str, Any]) -> Any:
        pass
1 Like

Please detail your problem.

Hello,
updated the initial post to what it should have been. Hope the issue is clear now.

If i understand what you are trying to accomplish, your LibA class should inherit LibraryComponent and not DynamicLibrary.

Second, you should be using @keyword decorator in LibA and thus, list of keywords should be automatically available so there’s no need for get_keyword_names().

And finally, run_keyword() shouldn’t be necessary either.

BUT take this all with a grain of salt …

I updated the initial post with the imports, so the example should be more clear.

@rasjani:
DynamicLibrary is an abstract baseclass for implementing the dynamic library interface and there is no LibraryComponent in PythonLibCore.

I am implementing a dynamic library, not a static library, so there are no methods as keywords and I need to implement get_keyword_names() and run_keyword().