nose class 运行过程

class testa():
def __init__(self):
print("__init__ was called!")

def setup(self):
print("setup was called")

def teardown(self):
print("teardown was called")

def test_alex(self):
print(self)
print("test_alex was called")

def test_alex2(self):
print(self)
print("test_alex2 was called")

 

 

D:\pycharm\alex-learn\falut-test2\222>nosetests lll.py -s -v
__init__ was called!
__init__ was called!
lll.testa.test_alex ... setup was called
<lll.testa instance at 0x0000000004CB9748>
test_alex was called
teardown was called
ok
lll.testa.test_alex2 ... setup was called
<lll.testa instance at 0x0000000004CB97C8>
test_alex2 was called
teardown was called
ok

 

注意:

可以看到是先初始化类,然后再分别测试各个function !!!! 使用的不同的对象去测试function !!!!

 

posted @ 2020-08-05 11:21  峡谷恶霸  阅读(97)  评论(0编辑  收藏  举报