我有两个脚本。脚本1标题为 schemeDetails 。第二个脚本是名为 temporaryFile 的测试脚本,它使用schemeDupails中的schemeSetup类创建schemeSetup对象。在我试图访问schemeSetup类中的方法insertScheme时,一切都很糟糕。
我使用以下内容导入了schemeDetails脚本:
import schemeDetails
reload(schemeDetails)
from schemeDetails import *
我可以创建schemeDetails对象并访问其属性
d = schemeDetails.schemeSetup() -- fine
print(d.scheme) -- fine
d.insertScheme() -- throws error
但尝试调用insertScheme函数会抛出错误
我不知道为什么会发生这种情况,因为导入声明对我来说很重要。任何建议赞赏
from sikuli import *
import os
class schemeSetup(object):
#Uses default values
def __init__(
self,
scheme = "GM",
cardNumber = "1234567A",
month = "December",
year = "2015",
setSchemeAsDefault = True):
#Provide default values for parameters
self.scheme = scheme
self.cardNumber = cardNumber
self.month = month
self.year = year
self.setSchemeAsDefault = setSchemeAsDefault
#schemeDetails is not a sub
# class of patient. It is simply defined within the patient class
# - there is a huge difference.
#====================================================#
#schemeDetails Function
def insertScheme(self):
print("insertScheme Works")
#r = Regions()
#r.description("Patient Maintenance", "schemeDetails")
#myRegion = r.createRegion()
#myRegion.highlight(1)
#click(myRegion.find(insertSchemeButton))
#click(myRegion.find(blankSchemeEntry))
#type(self.scheme + Key.ENTER + Key.ENTER)
#type(self.cardNumber + Key.ENTER)
#type(self.month + Key.ENTER)
#type(self.year + Key.ENTER)
#type(" ")
#unticks HT link, HT linking should be in a separate function
#====================================================#
#schemeDetails Function
def editScheme(self):
print("editScheme Works")
#====================================================#
def deleteScheme(self):
pass
#====================================================#
调用底部函数中的任何一个都不会产生错误可能很重要。如果我在editScheme下放置print(" Hello"),并使用s.editScheme调用该方法,程序将编译,但我没有输出。如果我运行print(s.editScheme),则返回None
答案 0 :(得分:0)
在将导入格式更改为此
之后,似乎现在已经修复了 import schemeDetails
from schemeDetails import schemeSetup
s = schemeDetails.schemeSetup()