Skip to content

Keep the state of an Imported Library #84

@Thonuck

Description

@Thonuck

I would like to use RobotKernel to develop larger Notebooks with multiple Cells.
For this notebook there is one library, which needs to be "setup" and keeps a state.
In current Implementation of the robotkernel it looks like, the imported Library is getting a new instance with each state.
Would it be possible, to keep one instance of a library over multiple cells?

I have the following code:

%%python module LibraryWithState

class LibraryWithState:
    def __init__(self):
        self.state = 0
        
    def get_increased_state(self):
        self.state += 1
        return self.state

And then the cells like

*** Settings ***
Library    LibraryWithState

*** Test Cases ***
Check the test Library
    Get Increased State

... which results in an output of the expected "1"
And the next cell like

*** Settings ***
Library    LibraryWithState

*** Test Cases ***
Check the test Library
    Get Increased State

this second output is still 1, but I wanted to see 2.

Is it possible, to achieve this? As I mentioned, seems with each cell, my python library gets freshly instantiated.
I would like to overcome this.

Thank you for any feedback or proposal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions