pytest详解-(2)setup、teardown介绍
-
模块级(setup_module/teardown_module)开始于模块始末调用,全局的
-
函数级(setup_function/teardown_function)只对函数用例生效,在函数始末调用(不在类中,在类外部)
-
类级(setup_class/teardown_class)在类始末调用
-
方法级(setup_method/teardown_method)在方法始末调用(在类中)
-
方法级(setup/teardown)在方法始末调用(在类中)
-
yield:yield前相当于setup,yield后相当于teardown,scpoe="module"与yield组合,相当于setup_module和teardown_module
注意调用顺序:setup_module>setup_class>setup_method>setup>teardown>teardown_method>teardown_class>teardown_module