Package: robotframework-pythonlibcore
Tools to ease creating larger test libraries forRobot Frameworkusing
Python. The Robot Frameworkhybridanddynamic library APIgives more
flexibility for library than the static library API, but they also sets requirements
for libraries which needs to be implemented in the library side. PythonLibCore
eases the problem by providing simpler interface and handling all the requirements
towards the Robot Framework library APIs.Code is stable and version 1.0 is already used bySeleniumLibraryandWhiteLibrary. The version 2.0 support changes in the Robot Framework
3.2.UsageThere are two ways to use PythonLibCore, either byHybridCoreor by usingDynamicCore.HybridCoreprovides support for the hybrid library API andDynamicCoreprovides support
for dynamic library API. Consult the Robot FrameworkUser Guide, for choosing the
correct API for library.Regardless which library API is chosen, both have similar requirements.Library must inherit either theHybridCoreorDynamicCore.Library keywords must be decorated with Robot Framework@keyworddecorator.Provide a list of class instances implementing keywords tolibrary_componentsargument in theHybridCoreorDynamicCore__init__.It is also possible implement keywords in the library main class, by marking method with@keywordas keywords. It is not requires pass main library instance in thelibrary_componentsargument.All keyword, also keywords implemented in the classes outside of the main library are
available in the library instance as methods. This automatically publish library keywords
in as methods in the Python public API.The example in below demonstrates how the PythonLibCore can be used with a library.Example"""Main library."""fromrobotlibcoreimportDynamicCorefrommystuffimportLibrary1,Library2classMyLibrary(DynamicCore):"""General library documentation."""def__init__(self):libraries=[Library1(),Library2()]DynamicCore.__init__(self,libraries)@keyworddefkeyword_in_main(self):pass"""Library components."""fromrobotlibcoreimportkeywordclassLibrary1(object):@keyworddefexample(self):"""Keyword documentation."""pass@keyworddefanother_example(self,arg1,arg2='default'):passdefnot_keyword(self):passclassLibrary2(object):@keyword('Custom name')defthis_name_is_not_used(self):pass@keyword(tags=['tag','another'])deftags(self):passPlugin APIIt is possible to create plugin API to a library by using PythonLibCore. This allows extending library
with external Python classes. Plugins can be imported during library import time, example by defining argumet
in library__init__which allows defining the plugins. It is possible to define multiple plugins, by seperating
plugins with with comma. Also it is possible to provide arguments to plugin by seperating arguments with
semicolon.fromrobot.api.decoimportkeyword# noqa F401fromrobotlibcoreimportDynamicCore,PluginParserfrommystuffimportLibrary1,Library2classPluginLib(DynamicCore):def__init__(self,plugins):plugin_parser=PluginParser()libraries=[Library1(),Library2()]parsed_plugins=plugin_parser.parse_plugins(plugins)libraries.extend(parsed_plugins)DynamicCore.__init__(self,libraries)When plugin class can look like this:classMyPlugi:@keyworddefplugin_keyword(self):return123Then Library can be imported in Robot Framework side like this:Library${CURDIR}/PluginLib.pyplugins=${CURDIR}/MyPlugin.py