kevlarjacket
kevlarjacket

Reputation: 188

robotframework is adding arguments where there are none: Type Error: takes no arguments (1 given)

Robot is telling me that I'm providing too many arguments to my keyword. I've boiled it down to a base case where I have a keyword that should do nothing:

def do_nothing():
    """
    Does absolutly nothing
    """

Calling this keywork like this:

*** Test Cases ***
testCaseOne
    do_nothing

Give this result:

TypeError: do_nothing() takes no arguments (1 given)

Adding a parameter to the keyword definition fixes the problem. Why does robot seem to pass 1 parameter to each keyword, even if there are no parameters in the test case?

Upvotes: 0

Views: 1074

Answers (1)

kevlarjacket
kevlarjacket

Reputation: 188

I found the answer here.

The issue has nothing to do with the robotframework, and has every thing to do with Python; Python implicitly passes the current instance of the class to method calls, but I needed to explicitly declare the parameter. This is customarily named self:

def do_nothing(self):

This test runs.

Upvotes: 1

Related Questions