run类中方法级别的setup和teardown.py

import pytest
import requests
class TestCase(object):
def test_case_01(self):
"""再执行三"""
assert 1

def test_case_02(self):
"""再执行六"""
assert {"title":"v2ex"} != {"title":"V2EX"}

def test_case_03(self):
"""再执行九"""
assert 1

def setup_class(self):
"""先执行一setup_class 类级别的setup"""
print("类级别的setup")

def teardown_class(self):
"""再执行十一teardown_class 类级别的teardown"""
print("类级别的teardown")

def setup_method(self):
"""再执行二setup_method 类中方法级别的setup"""
"""再执行五setup_method 类中方法级别的setup"""
"""再执行八setup_method 类中方法级别的setup"""
print("类中方法级别的setup")

def teardown_method(self):
"""再执行四teardown_method 类中方法级别的teardown"""
"""再执行七teardown_method 类中方法级别的teardown"""
"""再执行十teardown_method 类中方法级别的teardown"""
print("类中方法级别的teardown ")

if __name__ == '__main__':
pytest.main(["-s","run类中方法级别的setup和teardown.py"])
posted @ 2020-01-20 19:08  干it的小张  阅读(239)  评论(0编辑  收藏  举报