Skip to content

Can't import diffrent libs and use the same alias #2377

Description

@ddoraemon
*** Test Cases ***
1111
    @{a} =    Create list    5    2    3
    import library    Collections    WITH NAME    p1
    reload library    p1
    import library    String    WITH NAME    p1
    reload library    p1
    p1.Sort List    ${a}
    log    ${a}

p1 is Collections not String because:
robot/running/namespace.py:128
if lib.name in self._kw_store.libraries:
LOGGER.info("Test library '%s' already imported by suite '%s'"
% (lib.name, self._suite_name))

Activity

  1. pekkaklarck commented on May 26, 2016

    @pekkaklarck
    Member

    First of all, adding syntax highlighting for your Robot Framework and Python examples would make it a lot easier to understand the description. See here how to do it: https://guides.github.com/features/mastering-markdown/. Also, is Reload Library somehow relevant in these cases?

    The problem you describe is true and is caused by Robot caching libs and resources by their names. This caching has caused also other problems and it is possible that the functionality will change at some point. Such changes are potentially backwards incompatible and can thus only be done in a major release like RF 3.1.

    Could you clarify your use case for importing different libs with same name? Could you just use a variable containing the library name instead?

  2. ddoraemon commented on Oct 25, 2016

    @ddoraemon
    Author

    I need to import my libs in every testcase with test setup because of different arguments, and these cases are in one testsuite. I find that the second case's lib does not work with correct args because the lib does not be reimported in fact

  3. scathaig commented on Nov 15, 2016

    @scathaig

    At our site we have libraries that are basically only used as a remote library (using robotremoteserver), so that the suite is portable between different testbeds which all have their own remote library instance. To achieve this we pass in a configartion file containing all information regarding this testbed incl. IPs and ports of the remote libraries.

    But when a tester creates his suite (in RIDE) he also wants to have all the auto-completion and documentation. So the idea was to import the library locally to get only the documentation and later replace this instance at runtime with the remote one:

    *** Settings ***
    Library Testcenter WITH NAME stc        # for documentation in RIDE only
    
    *** Test Cases ***
    MyTestCase
        ${ip}    ${port}    Get Testcenter
        Import Library    Remote     ${ip}:${port}    WITH NAME    stc        # the actually used library instance
        stc.Streamblock Ethernet Add    ....
    

    As this is currently not working we have to work with libspec XML files, but it would be easier if we had to only deploy the libraries.

  4. pekkaklarck commented on Feb 4, 2017

    @pekkaklarck
    Member

    This is highly related to #2106. Needs to be decide about these together.

  5. added this to the v8.0 milestone on Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions