Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
PyPI

robotframework-pythonlibcore 4.4.1

pip install robotframework-pythonlibcore

Latest version

Released:

Tools to ease creating larger test libraries for Robot Framework using Python.

Verified details

These details have beenverified by PyPI
Maintainers
Avatar for snooz82 from gravatar.comsnooz82Avatar for tatu.aalto from gravatar.comtatu.aalto

Unverified details

These details havenot been verified by PyPI
Project links
Meta
  • License: Apache Software License (Apache License 2.0)
  • Author:Tatu Aalto
  • Tags robotframework, testing, testautomation, library, development
  • Requires: Python <4, >=3.8

Project description

Python Library Core

Tools to ease creating larger test libraries forRobotFramework using Python. The Robot Frameworkhybridanddynamic libraryAPIgives more flexibility for library than the static library API, but theyalso sets requirements for libraries which needs to be implemented inthe library side. PythonLibCore eases the problem by providing simplerinterface and handling all the requirements towards the Robot Frameworklibrary APIs.

Code is stable and is already used bySeleniumLibraryandBrowser library.Project supports two latest version of Robot Framework.

VersionActions StatusLicense

Usage

There are two ways to use PythonLibCore, either byHybridCore or by usingDynamicCore.HybridCore provides support forthe hybrid library API andDynamicCore provides support for dynamic library API.Consult the Robot FrameworkUserGuide,for choosing the correct API for library.

Regardless which library API is chosen, both have similar requirements.

  1. Library must inherit either theHybridCore orDynamicCore.
  2. Library keywords must be decorated with Robot Framework@keyworddecorator.
  3. Provide a list of class instances implementing keywords tolibrary_components argument in theHybridCore orDynamicCore__init__.

It is also possible implement keywords in the library main class, by marking method with@keyword as keywords. It is not required pass main library instance in thelibrary_components argument.

All keyword, also keywords implemented in the classes outside of themain library are available in the library instance as methods. Thisautomatically publish library keywords in as methods in the Pythonpublic API.

The example in below demonstrates how the PythonLibCore can be used witha 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):pass

Plugin API

It is possible to create plugin API to a library by using PythonLibCore.This allows extending library with external Python classes. Plugins canbe imported during library import time, example by defining argumet inlibrary [__init__]{.title-ref} which allows defining the plugins. Itis possible to define multiple plugins, by seperating plugins with withcomma. Also it is possible to provide arguments to plugin by seperatingarguments 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):return123

Then Library can be imported in Robot Framework side like this:

Library${CURDIR}/PluginLib.pyplugins=${CURDIR}/MyPlugin.py

Translation

PLC supports translation of keywords names and documentation, but arguments names, tags and typescan not be currently translated. Translation is provided as a file containingJson and as aPath object. Translation is provided intranslation argument in theHybridCore orDynamicCore__init__. Providing translationfile is optional, also it is not mandatory to provide translation to all keyword.

The keys of json are the methods names, not the keyword names, which implements keyword. Valueof key is json object which contains two keys:name anddoc.name key contains the keywordtranslated name anddoc contains keyword translated documentation. Providingdoc andname is optional, example translation json file can only provide translations onlyto keyword names or only to documentatin. But it is always recomended to provide translation tobothname anddoc.

Library class documentation and instance documetation has special keys,__init__ key willreplace instance documentation and__intro__ will replace libary class documentation.

Example

If there is library like this:

frompathlibimportPathfromrobotlibcoreimportDynamicCore,keywordclassSmallLibrary(DynamicCore):"""Library documentation."""def__init__(self,translation:Path):"""__init__ documentation."""DynamicCore.__init__(self,[],translation.absolute())@keyword(tags=["tag1","tag2"])defnormal_keyword(self,arg:int,other:str)->str:"""I have doc        Multiple lines.        Other line.        """data=f"{arg}{other}"print(data)returndatadefnot_keyword(self,data:str)->str:print(data)returndata@keyword(name="This Is New Name",tags=["tag1","tag2"])defname_changed(self,some:int,other:int)->int:"""This one too"""print(f"{some}{type(some)},{other}{type(other)}")returnsome+other

And when there is translation file like:

{"normal_keyword":{"name":"other_name","doc":"This is new doc"},"name_changed":{"name":"name_changed_again","doc":"This is also replaced.\n\nnew line."},"__init__":{"name":"__init__","doc":"Replaces init docs with this one."},"__intro__":{"name":"__intro__","doc":"New __intro__ documentation is here."},}

Thennormal_keyword is translated toother_name. Also this keyword documentions istranslted toThis is new doc. The keyword isname_changed is translted toname_changed_again keyword and keyword documentation is translted toThis is also replaced.\n\nnew line.. The library class documentation is translatedtoReplaces init docs with this one. and class documentation is translted toNew __intro__ documentation is here.

Project details

Verified details

These details have beenverified by PyPI
Maintainers
Avatar for snooz82 from gravatar.comsnooz82Avatar for tatu.aalto from gravatar.comtatu.aalto

Unverified details

These details havenot been verified by PyPI
Project links
Meta
  • License: Apache Software License (Apache License 2.0)
  • Author:Tatu Aalto
  • Tags robotframework, testing, testautomation, library, development
  • Requires: Python <4, >=3.8

Download files

Download the file for your platform. If you're not sure which to choose, learn more aboutinstalling packages.

Source Distribution

robotframework-pythonlibcore-4.4.1.tar.gz (12.8 kBview details)

UploadedSource

Built Distribution

Filter files by name, interpreter, ABI, and platform.

If you're not sure about the file name format, learn more aboutwheel file names.

Copy a direct link to the current filters

robotframework_pythonlibcore-4.4.1-py2.py3-none-any.whl (12.5 kBview details)

UploadedPython 2Python 3

File details

Details for the filerobotframework-pythonlibcore-4.4.1.tar.gz.

File metadata

File hashes

Hashes for robotframework-pythonlibcore-4.4.1.tar.gz
AlgorithmHash digest
SHA2562d695b2ea906f5815179643e29182466675e682d82c5fa9d1009edfae2f84b16
MD513924c9fbbf8b26259badcb3f22d79ee
BLAKE2b-25671895dc8c8186c897ee4b7d0b2631ebc90e679e8c8f04ea85505f96ad38aad64

See more details on using hashes here.

File details

Details for the filerobotframework_pythonlibcore-4.4.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for robotframework_pythonlibcore-4.4.1-py2.py3-none-any.whl
AlgorithmHash digest
SHA256e0517129522aaa039eb2a28fd3d9720b7a0be0b90d0cbcb153a6c8016bb9e973
MD551853f6f316e9cc52b8266f184a5d8fe
BLAKE2b-256ac6447d8403c7c0af89b46461640a2f67e49a5778062b8dd6eb3e128aa3c50cc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security SponsorDatadog MonitoringDepot Continuous IntegrationFastly CDNGoogle Download AnalyticsPingdom MonitoringSentry Error loggingStatusPage Status page

[8]ページ先頭

©2009-2025 Movatter.jp