实际上我看不出我在这里做错了什么,但我想这是一个非常简单和基本的问题:
模块 1 称为 Widget17_Sorter.py:
class Widget17_Sorter(object):
def get_data_from_database(self, database_name, user, password, host ):
...do stuff here...
模块 2 称为 Test_Widget17_Sorter.py(实际上是一个单元测试)
import Widget17_Sorter
class Test(unittest.TestCase):
...do some other stuff here...
def test_get_data_from_database(self):
sorter = Widget17_Sorter.Widget17_Sorter()
raw_data = sorter.get_data_from_database( self.database_name,
self.user, self.password, self.host )
执行测试时,我收到以下错误消息:
ERROR: test_get_data_from_database (__main__.Test)
----------------------------------------------------------------------
Traceback (most recent call last):
File "TestWidget17_Sorter.py", line 50, in test_get_data_from_database
raw_data = sorter.get_data_from_database( self.database_name,
AttributeError: 'Widget17_Sorter' object has no attribute 'get_data_from_database'
为什么?