Python version: 3.7.8 Robot framework: 3.1.2
I have a python class where specified a class variable to store and retrieve data later in robot framework.
Example: class1
class test1():
__testvar__=[]
def set_data(self, data):
test1.__testvar__.append(data)
def get_data(self)
return test1._testvar__
def main_calling_method(self):
...something...
self.set_data(data)
class2:
from ...test1 import test1
class test2():
t=test1()
def get_method_data(self)
return test2.t.main_calling_method()
Robot framework: Robot1 File :
*** Settings ***
Library Pathto\test2.py
*** Keywords ***
callingkeyword
${body}= get_method_data
[RETURN] ${body}
main keyworkd
${response}= callingkeyword
[RETURN] ${response}
Robot2 File:
*** Settings ***
Resoure Pathto\Robot1.robot
Library Pathto\test1.py
*** Keywords ***
testing
${temp}= main keyworkd
${data}= get_data
log to console ${data}
Expected Results:- Value of class variable --testvar__ to be printed in console
Actual Results:- Prints empty list.
If I run the method 'get_data' from python, it prints the data that are added as part of set_data but not producing the same results while running from robot framework.
However, if I call set method like below, before calling get_method, then prints the data properly.
*** Keywords ***
testing
${temp}= main keyworkd
set_data= testing
${data}= get_data
log to console ${data}
Could you please assist where the issue is?
Note: The above scenarios are dummy code for understanding purpose only as I can't share the actual project codes due to security concerns.
datainside ofmain_calling_methodappears on the console.