fixtures即可以表示测试用例的开始和结束,也可以表示测试类和测试模块的开始和结束。

 import unittest

 def setUpModule():
print("test module start >>>>>>>>>") def tearDownModule():
print("test module end >>>>>>>>>>>>>") class Test (unittest.TestCase):
@classmethod
def setUpClass(cls):
print("test class start=======>") @classmethod
def tearDownClass(cls):
print("test class end =====>") def setUp(self):
print("test case start -->") def tearDown(self):
print("test case end ---->") def test_case(self):
print("test case") def test_case2(self):
print("test case2") if __name__ == '__main__':
unittest.main ()

注:

setUpModule/tearDownModule:在整个模块的开始与结束时被执行

setUpClass/tearDownClass:在测试类的开始与结束时被执行

setUp/tearDown:在测试用例的开始与结束时被执行。

******;setUpClass/tearDownClass写法是:要通过@calssmethod进行装饰,其次参数为cls。并且cls与self并没有什么特别之处。都只是别是类方法的第一个参数,只是约定俗成的习惯,也可以用abc来命名。

Python+selenium之fixtures的更多相关文章

  1. python+selenium 浏览器的问题

    以前用selenium调用firefox是不需要驱动的,最近安装了python3.52+最新的firefox 发现调不起来了 搜索以后发现Firefox 47+需要搞个firefox的驱动 gecko ...

  2. 一次完整的自动化登录测试-基于python+selenium进行cnblog的自动化登录测试

    Web登录测试是很常见的测试!手动测试大家再熟悉不过了,那如何进行自动化登录测试呢!本文作者就用python+selenium结合unittest单元测试框架来进行一次简单但比较完整的cnblog自动 ...

  3. Python + Selenium 实现登录Office 365

    最近捡起之前用的Python + Selenium实现工作中需要的登录Office 365功能.(吐槽:国内网络真是卡,登录Office 365实属不易.另外Selenium这样的网站都要墙,无法理解 ...

  4. python+selenium+Robot

    准备工作: 1.下载python2.7 http://python.org/getit/ 2.下载下载setuptools [python 的基础包工具] 可以帮助我们轻松的下载,构建,安装,升级,卸 ...

  5. python+selenium运行报错UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)

    使用python+selenium运行自动化脚本时,打印某一段文字出现UnicodeEncodeError: 'ascii' codec can't encode characters in posi ...

  6. Functional testing - python, selenium and django

    Functional testing  - python selenium django - Source Code : from selenium import webdriverfrom sele ...

  7. python selenium自动化(二)自动化注册流程

    需求:使用python selenium来自动测试一个网站注册的流程. 假设这个网站的注册流程分为三步,需要提供比较多的信息: 在这个流程里面,需要用户填入信息.在下拉菜单中选择.选择单选的radio ...

  8. 使用python selenium进行自动化functional test

    Why Automation Testing 现在似乎大家都一致认同一个项目应该有足够多的测试来保证功能的正常运作,而且这些此处的‘测试’特指自动化测试:并且大多数人会认为如果还有哪个项目依然采用人工 ...

  9. Python+Selenium WebDriver API:浏览器及元素的常用函数及变量整理总结

    由于网页自动化要操作浏览器以及浏览器页面元素,这里笔者就将浏览器及页面元素常用的函数及变量整理总结一下,以供读者在编写网页自动化测试时查阅. from selenium import webdrive ...

随机推荐

  1. Oracle查看表空间和表空间中的对象

    select * from user_tables;--查询所有用户表 select username,default_tablespace from user_users;--查询当前表空间sele ...

  2. 01_SQlite数据库简介

  3. Auto Layout Guide----(二)-----Auto Layout Without Constraints

    Auto Layout Without Constraints 没有约束的自动布局 Stack views provide an easy way to leverage the power of A ...

  4. 《精通Spring4.X企业应用开发实战》读后感第四章(Application中Bean的生命周期)

    package com.smart.beanfactory; import org.springframework.beans.BeansException; import org.springfra ...

  5. VS中运行后控制台窗口一闪就没了

    使用VS2010后,用Ctrl+F5运行程序,结果控制台窗口一闪就没了,也没有出现”press any key to continue…” 或者“请按任意键继续”. 出现这种原因,主要是建立工程时选用 ...

  6. 3dmax 法线重置

    从一个模型分离部位时,分离出的部分,面法线发生了混乱,左边原始模型,右边分离后 重置法线方法 对模型(比如对分离出的下半身)添加 EditoNormal修改器 选中模型部位 添加Edit Normal ...

  7. android studio 生成引用arr

    http://blog.csdn.net/luyanjun07/article/details/51558151 1.背景 jar:无法包含资源文件 library:可以包含资源文件 但是引入显得比较 ...

  8. poj 2407 欧拉函数裸题

    http://poj.org/problem?id=2407 题意:多组数据,每次输入一个数 ,求这个数的欧拉函数 int euler_phi(int n){//单个欧拉函数 int m=(int)s ...

  9. JVM虚拟机的大概了解(新人面试必看!)

    一. 引言,环境安装测试中的代码解析       1. HotSpot(TM) 64-bit Server VM(build 25.181-b13,mixed mode),这是多种     HotSo ...

  10. MySQL事务学习