有些事情真的发生了,我几乎一天都无法下决心
示例如下:尝试一个简单的方法从一个类调用到另一个类来解决问题,因为我今天早上也经历了这个臭名昭著的问题.所以尝试了一种简单的方法.两类: HomePageAlone OnDemand
HomePageAlone -定义了一个测试"def test_E_Access(self):“在OnDemand中调用方法我得到了以下错误。
守则如下:
HomePageAlone
from sikuli import *
from OnDemand import *
import OnDemand
class homePage(unittest.TestCase):
def setUp(self):
print("Test")
def test_E_Access(self):
callMethod = OnDemand()
callMethod.calc() # Line#15
suite = unittest.TestSuite()
suite.addTest(homePage('test_E_Access'))
unittest.TextTestRunner(verbosity=2).run(suite)OnDemand
from sikuli import *
class OnDemand(object):
def setUp(self):
print("setup")
def calc(self):
print ("This is calling")日志消息
======================================================================
错误:(main.homePage) test_E_Access
回溯(最近一次调用):文件"C:\DOCUME~1\Senthil.S\LOCALS~1\Temp\sikuli-6018543662740221054.py",第15行,在test_E_Access callMethod.calc(self) # Line#15 AttributeError中:'OnDemand‘对象没有属性'calc’
0.016s的Ran 1测试
失败(errors=1)
另一次尝试:我尝试使用下面的代码片段作为您的建议-它总是抛出AttributeError:'OnDemandPopular‘对象没有属性'calc’
导入OnDemandPopular ondemand = OnDemandPopular.OnDemandPopular() ondemand.calc()
请帮帮忙
发布于 2014-06-25 10:30:03
您应该从OnDemand模块导入OnDemand类;
from OnDemand import OnDemandHomePageAlone
import unittest
from OnDemand import OnDemand
class homePage(unittest.TestCase):
def setUp(self):
print("Test")
def test_E_Access(self):
callMethod = OnDemand()
callMethod.calc() # Line#15
suite = unittest.TestSuite()
suite.addTest(homePage('test_E_Access'))
unittest.TextTestRunner(verbosity=2).run(suite)OnDemand
class OnDemand(object):
def setUp(self):
print("setup")
def calc(self):
print ("This is calling")输出为;
This is calling
test_E_Access (HomePageAlone.homePage) ... ok
Test
This is calling
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
Test
This is callinghttps://stackoverflow.com/questions/24406130
复制相似问题