0
我已經在python for robotframework中構建了一個混合庫。此API的其中一種方法返回一個字符串,我想將其分配給測試中的robotframework變量。robotframework混合庫關鍵字不會返回值
${sms_1_2}= encrypt_sms_return_ciphered [email protected] [email protected] sms1to2
我已驗證的encrypt_sms_return_ciphered的Python代碼沒有返回一個字符串。但問題是robotframework變量被分配給None。
下面是方法的代碼:
@InstanceIndex.check_short_name
def encrypt_sms__return_ciphered(self, sender, receiver, clearsms):
self.encrypt_sms(sender, receiver, clearsms)
ClientIndex.success_if(sender, "isSmsSent", receiver, clearsms)
cipheredsms = self.smsSent[receiver, clearsms]
del self.smsSent[receiver, clearsms]
return cipheredsms
這裏是check_short_name裝飾的代碼:
@staticmethod
def check_short_name(method):
def wrapper(self, short_name, *args, **kwargs):
if short_name != self.short_name:
try:
getattr(self.collection.iterate(), method.__name__)(short_name, *args, **kwargs)
except StopIteration:
raise Exception("item \"%s\" is not a member of %s, or method \"%s\" is not defined for any member of %s" % (short_name, self.collection.name, method.__name__, self.collection.name))
else:
self.collection.rewind()
return method(self, short_name, *args, **kwargs)
return wrapper