If a python class contains a __eq__ method, robot framework is unable to get the keywords from the class (The tests run and pass if the __eq__ method is commented out). For example, if my Python class (implemented in TestClass.py) is
class TestClass(object):
def __init__(self, arg1, arg2):
self.arg1 = arg1
self.arg2 = arg2
def get_arg1(self):
return self.arg1
def get_arg2(self):
return self.arg2
def __eq__(self, other):
return self.arg1 == other.arg1 and self.arg2 == other.arg2
and my robot file (TestClass.robot) is
*** Settings ***
Library TestClass 1 2 WITH NAME First_Lib
*** Variables ***
*** Test Cases ***
MyTest1
${result}= First_Lib.get arg1
Should be equal as integers ${result} 1
MyTest2
${result}= First_Lib.get arg2
Should be equal as integers ${result} 2
I see the following error message when running robot v3.0.2.
[ ERROR ] Error in file 'TestClass.robot': Getting keyword names from library 'TestClass' failed: AttributeError: type object 'object' has no attribute 'arg1'
I'd like to understand if this is an unsupported use of the robot framework and if so, is there a recommended solution to rewrite/modify the class under test to avoid this error.
By executing the robot framework code through the debugger, I see that the error is originating from the method _get_handler_method in the class _ClassLibrary (in the file testlibraries.py). Being a newbie with the robot framework, I'm not sure how to address this problem.
Any suggestions will be of great help !!