class TestUM(unittest.TestCase):
def test_Dynasty_init(self):
try:
self.p = ModelInterface(r"E:\HIL\07_Tests\AT_Dynasty_models\AT745\RTM_AT_745.dml") #any dml file should do here
except Exception:
self.fail("Dynasty initialization raised ExceptionType unexpectedly!")
def test_Dynasty_check(self):
self.p.check()
在第9行,我得到以下错误:
"AttributeError: 'TestUM' object has no attribute 'p'"
我不明白。^在test_Dynasty_check
函数中,{
这可能取决于是否在类实例的test\u dianary\u check()之前调用test\u init()。你知道吗
您应该使用
setUp()
和tearDown()
作为初始化/销毁代码。你知道吗如果我没记错的话,
unittest
库按字母顺序运行以test
开头的所有函数。意思是test_Dynasty_check
在test_Dynasty_init
之前运行。编辑:顺序无关紧要,因为每个测试都将从TestCase类的新的实例运行。你知道吗相关问题 更多 >
编程相关推荐