zoukankan      html  css  js  c++  java
  • pytest,setup和teardown

    用例运行级别

    模块级(setup_module/teardown_module)开始与模块始末,全局的

    函数级(setup_function/teardown_function)只对函数用例生效(不在类中)

    类级(setup_class/teardown_class)只在类中前后运行一次(在类中)

    方法级(setup_methon/teardown_methon)开始与方法始末(在类中)

    类里面的(setup/teardown)运行在调用方法前后

    # 模块级(setup_module / teardown_module)开始与模块始末,全局的
    #
    # 函数级(setup_function / teardown_function)只对函数用例生效(不在类中)
    #
    # 类级(setup_class / teardown_class)只在类中前后运行一次(在类中)
    #
    # 方法级(setup_methon / teardown_methon)开始与方法始末(在类中)
    #
    # 类里面的(setup / teardown)运行在调用方法前后
    
    import pytest
    
    class TestCase01(object):
        @classmethod
        def setup_class(cls):
            print('setup_class')
    
        @classmethod
        def teardown_class(cls):
            print('teardown_class')
        def test1(self):
            print('test1')
    
        def test2(self):
             print('test2')
    
    
    def setup_function():
        print('setup_function')
    def teardown_function():
        print('teardown_function')
    
    def setup_module():
        print('setup_modul')
    def teardown_module():
        print('teardown_module')
    
    
    
    def test1(self):
        print('test1')
    def test2(self):
        print('test2')
    
    
    if __name__ == '__main__':
        pytest.main(['test07.py','-sv'])
  • 相关阅读:
    Hive-排序
    008-Java的StringBuilder和StringBuffer
    Java-向上转型后调用方法和属性的注意事项
    Linux命令使用总结
    008-字符串替换函数
    hive常用函数
    007-Java可变个数形参重载【数组和...】
    006-Java的break和continue
    005-Java运算符
    暑期实习面试——中天联科,算法实习
  • 原文地址:https://www.cnblogs.com/yronl/p/12958153.html
Copyright © 2011-2022 走看看