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

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

机器人告诉我,我为我的关键字提供了太多参数。我把它归结为一个基本情况,我有一个什么都不应该做的关键字:

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

像这样调用这个键:

*** Test Cases ***
testCaseOne
    do_nothing

给出这个结果:

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

在关键字定义中添加参数可以解决问题。为什么机器人似乎向每个关键字传递 1 个参数,即使在测试用例中没有参数?

我找到了答案here

问题与robotframework无关,与Python有关; Python 将 class 的当前实例隐式传递给方法调用 ,但我需要显式声明参数。这通常被命名为 self:

def do_nothing(self):

此测试运行。