HyperRobotFrameworkPlugin icon indicating copy to clipboard operation
HyperRobotFrameworkPlugin copied to clipboard

Support for Library imports, when it's a python package

Open myjniak opened this issue 1 year ago • 2 comments

Suppose we have this kind of basic python package: image where robot_interface.py contains class MyModuleB and __init__.py from robot_interface imports MyModuleB.

Robot Framework fully supports that scenario, but the plugin does not.

So, when looking for the correct class in the imported Library, the plugin would also have to look into subimports. image

Please also refer to the full example here to reproduce the issue: https://github.com/myjniak/hyper-robot-issue

myjniak avatar Jul 11 '24 11:07 myjniak

I also noticed this issue before, unfortunately, I didn't find a proper way to resolve it.

To me, it's an edge case, because in your module name is the same with kw class name MyModuleB and robot is using the name string to find the kw.

Suppose your modify your module name to foo:

lib
    ->   foo
                -> __init__.py
                -> robot_interface.py

when you import lib:

Library    lib.foo

robot will not find any kw. The correct import way should be:

Library    lib.foo.ModuleB
Library    lib.foo.ModuleX

jnhyperion avatar Jul 12 '24 02:07 jnhyperion

So, instead of:

Library   Package.Subpackage

we can do this:

Library   Package.Subpackage.Module.Class

I think for the sake of good IDE navigation, we will use that longer syntax for now :) Thanks for the nice hint!

myjniak avatar Jul 12 '24 08:07 myjniak