boakley / robotframework-hub

Web app for accessing robot framework assets
https://github.com/boakley/robotframework-hub/wiki
Apache License 2.0
170 stars 60 forks source link

Python libraries that are implemented as class and when library takes arguments without default value are not parsed by the rf-hub #39

Closed aaltat closed 8 years ago

aaltat commented 10 years ago

Given that I have a library that looks like this:

class MyLibrary():
    def __init__(self, arg):
        self.arg = arg

    def my_keyword(self):
        """
        Doc
        """
        print self.arg

When I run rf-hub like this:

python -m rfhub  --interface 0.0.0.0 C:\MyLibrary

Then I see error:

bummer: Test Library 'MyLibrary' expected 1 argument, got 0.
tornado web server running on http://0.0.0.0:7070

And I did not expect an error.

So is this a bug in the rf-hub, because arguments without default values are supported by the Robot Framework.

As an workaround, I can specify a default value the argument but I would like to have support to arguments that do not have default value. Perhaps it should be handled in the same way as in libdoc:

c:\>python -m robot.libdoc MyLibrary.py::1 MyLibrary.html
aaltat commented 10 years ago

Ah, did notice that it actually works like in libdoc, but one has to define the exact path to the library, example like this:

python -m rfhub  --interface 0.0.0.0 C:\MyLibrary\MyLibrary.py::1

This leaves one minor thing. When there is many libraries in a repository, to get completely out of the error, user must define path to all libraries and not just the when src directory where the libraries are found. Example this will cause the error

python -m rfhub  ^
--interface 0.0.0.0 ^
C:\path\to\repo\src ^
C:\path\to\repo\src\MyLibrary\MyLibrary.py::1

But this will not generate the error:

python -m rfhub  ^
--interface 0.0.0.0 ^
C:\path\to\repo\src\OtherLib1 ^
C:\path\to\repo\src\OtherLib2 ^
...
C:\path\to\repo\src\MyLibrary\MyLibrary.py::1

But if there are many libraries, might be annoying to keep track of the library paths. But then a again, perhaps I should write a better script to walk over the paths in the src tree.

Perhaps best solution would be to write better doc, who these can be handled properly.