Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple imports of library does not create new instance #5122

Open
oetzus opened this issue Apr 26, 2024 · 0 comments
Open

Multiple imports of library does not create new instance #5122

oetzus opened this issue Apr 26, 2024 · 0 comments

Comments

@oetzus
Copy link

oetzus commented Apr 26, 2024

According to the user guide, "If a library is imported multiple times with different arguments, a new instance is created every time regardless the scope."
But that does not seem to work for me.

Here is the example test case I use:

*** Settings ***
Library          testlib.py    num=1    AS    Test
Library          testlib.py    num=2    AS    Test
Library          testlib.py    num=3    AS    Test

*** Test Cases ***
Example Test
    Log Params
    BuiltIn.Import Library    ${CURDIR}/testlib.py    num=4    AS    Test
    Log Params

with the following example library:

from robot.api import logger

class testlib():

    ROBOT_LIBRARY_SCOPE = 'GLOBAL'

    def __init__(self, num):
        self.num = num

    def log_params(self):
        logger.console(f'num: {self.num}')

As I import the library each time with a different argument, I would expect, that a new instance of the library is created that overwrites the current instance. Instead, the very first instance of the library seems to be used as the output of both calls of Log Params is 1.

Did I understand the note in the user guide wrong or is this an unintended behaviour?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant