Prototyping Libraries

Prototyping LibrariesΒΆ

To ease prototyping Python keywords, a code cell could start with %%python module ModuleName magic words to describe a new keyword library as a Python module. This should work well at least class based keyword library.

%%python module XKCDLibrary

import requests

URL = 'https://xkcd.com/info.0.json'


class XKCDLibrary:
    def get_latest_strip_url(self):
        """Return URL of the latest XKCD strip"""
        response = requests.get(URL)
        return response.json()['img']

Once the library has been defined, it could be imported and used as any Python keyword library.

*** Settings ***

Library  XKCDLibrary
*** Tasks ***

Show the latest XKCD
    Get latest strip URL

The library is reloaded before every test or task execution, but currently its keywords are scanned for auto-completion and contextual help only during the first execution (after the latest kernel restart).