当前位置:网站首页>3.5 测试类的setup和teardown
3.5 测试类的setup和teardown
2022-06-12 21:52:00 【redrose2100】
3.5.1 类级别的setup和teardown
测试类中类级别的setup和teardown的方法为setup_class和teardown_class,setup_class是在当前测试类的所有测试方法执行之前执行,而teardown_class则是在当前测试类的所有测试方法执行之后执行,setup_class主要用于当前测试类所有测试方法的公共的前提操作,比如环境配置、变量初始化等等,而teardown则用于当前所有类执行完成之后需要清理的操作,比如清理setup_class中配置的环境变量等,需要注意的是setup_class和teardown_class只会执行一次。
下面用一个实例演示(https://gitee.com/redrose2100/pytest-demo/blob/master/ch03/ex_008/test_demo.py)
代码如下:
class TestDemo(object):
def setup_class(self):
print("in setup_class ...")
def teardown_class(self边栏推荐
- SQL tuning guide notes 10:optimizer statistics concepts
- How to implement a simple publish subscribe mode
- 【Proteus仿真】简易数码管定时器时钟
- Ansible playbook and variable (II)
- 疼痛分级为什么很重要?
- Icml2022 | galaxy: active learning of polarization map
- Cloning PDB with ADG standby
- Ansible PlayBook et ansible roles (3)
- Ansible Roles-项目案例(四)
- MySQL介绍和安装(一)
猜你喜欢

【概率论与数理统计】期末复习抱佛脚:公式总结与简单例题(完结)

多线程模型下的生产者消费者模式

Icml2022 | galaxy: active learning of polarization map

Icml2022 | Galaxy: apprentissage actif des cartes de polarisation

SQL调优指南笔记15:Controlling the Use of Optimizer Statistics

孙老师版本JDBC(2022年6月12日21:34:25)

Ansible playbook和Ansible Roles(三)

Open source background management system suitable for outsourcing projects

SQL调优指南笔记9:Joins

SQL tuning guide notes 16:managing historical optimizer statistics
随机推荐
Digraph deep copy
Unity 常用3D数学计算
VagrantBox重新安装vboxsf驱动
SQL调优指南笔记11:Histograms
SQL调优指南笔记9:Joins
PCB package download website recommendation and detailed usage
Can tonghuashun open an account? Is it safe to open an account in tonghuashun? How to open a securities account
Ansible playbook和Ansible Roles(三)
2021 rust survey results released: 9354 questionnaires collected
【Proteus仿真】简易数码管定时器时钟
[C language] data type occupation
Compiling process of OpenSSL and libevent on PC
Logstash timestamp converted to UNIX nanosecond nano second time
What is the difference between a user thread and a daemon thread?
关于 安装Qt5.15.2启动QtCreator后“应用程序无法正常启动0xc0000022” 的解决方法
Vagrantbox reinstalling the vboxsf driver
June training (day 10) - bit operation
Open source background management system suitable for outsourcing projects
NoSQL - redis configuration and optimization (II) high availability, persistence and performance management
SQL调优指南笔记17:Importing and Exporting Optimizer Statistics