Skip to content

Import Lib and Get Lib Instance doc clarifcation #2165

Closed

Description

@yahman72

It would be good to have a description how the BuiltIn.Import Library behave if the library in question:

  1. is already loaded (e.g. a new instance is created and the old one is discarded)
  2. Is there a difference if Import Library is executed inside RF runtime (e.g. in a robot-file) or outside RF runtime (e.g. in MyOwnLib's init() method e.g. self._ssh = SSHLibrary() --> is the SSHLIbrary library instance now only available inside MyOwnLib or is it also available inside RF runtime)

and the same goes for BuiltIn.Get Library Instance i.e. what happens if the library in question:

  1. is already loaded
  2. is not yet loaded

This is important if the library in question is stateful.

Import Resource could also be documented similarly i.e. what happens with the variables imported from that resource file. Import Variables seems already have this info i.e. 'These variables override possible existing variables with the same names'.

Activity

  1. pekkaklarck commented on Oct 1, 2015

    @pekkaklarck
    Member

    Different ways to import libraries ought to be documented in the User Guide:
    http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#using-test-libraries

    Please clarify how you would like documentation to be enhanced. I read the description twice but couldn't understand it fully. Notice also that general questions should be rather sent to mailing list or other forums. This tracker is for bug reports and concrete enhancement requests.

  2. yahman72 commented on Oct 2, 2015

    @yahman72
    ContributorAuthor

    How to import libraries is documented indeed, but how they behave if imported multiple times is not documented (or the documentation is inconsistent) - that's why I opened an issue.

    Maybe I should have opened a couple of issues, because there are now a couple of topics here.
    Anyway, I'll come up with more details ASAP - busy with some other stuff at the moment...

  3. yahman72 commented on Oct 9, 2015

    @yahman72
    ContributorAuthor

    As promised, more examples:

    1. Import Library missing documentation:
      What happens if the library is already imported in the current scope? i.e.
      a) if the library contains variables are their values overwritten? I guess not
      b) if the library is "stateful" (like SSHLibrary) is the state preserved (e.g. with SSH the status of the ssh connections)? I guess yes.
      c) if the library supports arguments e.g. SSHLib already imported with timeout = 5s --> re-import with timeout = 15s --> what is now the timeout value after the 2nd import? still 5s

    2. Import Resource missing documentation:
      What happens if the resource is already imported in the current scope? i.e.
      a) if the resource contains variables are their values overwritten? I guess not

    3. Get Library Instance missing documentation:
      a) what happens if the library is not loaded? --> KW fails i.e. one should run Import Library first.

    Let me know if you agree with these updates. In that case I'll create a PR.

  4. pekkaklarck commented on Oct 9, 2015

    @pekkaklarck
    Member

    Answers:

    1. Depends is the library imported again with same arguments or not. In the former case the library is not imported again, but that is likely to change in RF 3.0 due to Imported libraries should not be cached #2106. Notice that I didn't understand what you mean with "library contains variables".
    2. Resources are nor re-imported, but also this may change in RF 3.0. See Resource files should be re-processed when imported #2099 for details.
    3. Get Library Instance fails if the specified library doesn't exist. I think that is pretty obvious, but making docs more explicit wouldn't harm.

    I doubt it makes chance to update docs about 1. or 2. because they are likely to change in the next version. I actually think this whole issue should be closed in favor of #2106, #2099 and also #2101. Please submit a separate issue and pull request about enhancing Get Library Instance if you think it is important.

  5. yahman72 commented on Oct 9, 2015

    @yahman72
    ContributorAuthor

    thanks
    wrt 1) "with same arguments" do you refer to the WITH NAME syntax or MyLib my_arg=True syntax or both? #2105 mentions only WITH NAME
    #2106 would make things clearer - but could also break a lot of things, more in #2106
    ("contains variables" means either "has global variables that are used internally, more or less the same thing as stateful lib" or "imports variable into RF runtime e.g. like RemoteSwingLib imports ${REMOTESWINGLIBRARYPATH}" --> however the behaviour is now clear)

    wrt 2) ok, same here - clearer but could break things

    wrt 3) ok

    and yeah, let's close this one. I'll make that PR.

  6. pekkaklarck commented on Oct 9, 2015

    @pekkaklarck
    Member

    With same arguments I meant both arguments passed to the library itself and possible WITH NAME usage. Notice that in both of these cases the old library stays imported too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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