Pytest - 1

2023年3月29日

import pytest , time

class Test_case():

    def setup_class(self):

        print("类前执行一次")           #类前执行一次

    def teardown_class(self):

        print("类后执行一次")           #类后执行一次

    # def setup(self):

    #     print("每个用例前执行一次")    #每个用例前执行一次

    # def teardown(self):

    #     print("每个用例后执行一次")    #每个用例后执行一次

    @pytest.mark.skip(reason="无理由跳过")          # 无路由跳过

    def test1(self):

        print("test1")

        # time.sleep(30)

        # raise Exception("this is a exception")   # 抛出异常

    def test2(self):

        print("test2")

    def test3(self):

        print("test3")

if __name__ == "__main__":

    pytest.main()

py.test.exe .test.py -vs

服务器托管,北京服务器托管,服务器租用 http://www.hhisp.net
机房租用,北京机房租用,IDC机房托管, http://www.e1idc.net

hackdl

咨询热线/微信 13051898268