当前位置: 首页 > wzjs >正文

网站手机验证码怎么做网络推广方式有哪几种

网站手机验证码怎么做,网络推广方式有哪几种,自己创造网站,介绍做素食的网站规范 1、首先创建 py 文件命名以 test_ 开始或者以 _test 结尾 2、若是新建类,测试类需要以 Test_开头 3、测试用例(方法)需要以 test_开头 assert 断言 assert xx:判断 xx 为真 assert not xx:判断 xx 不为真 asse…

规范

1、首先创建 py 文件命名以 test_ 开始或者以 _test 结尾

2、若是新建类,测试类需要以 Test_开头

3、测试用例(方法)需要以 test_开头

assert 断言

assert xx:判断 xx 为真

assert not xx:判断 xx 不为真

assert a in b:判断 b 包含 a

assert a == b:判断 a 等于 b

assert a !=b:判断 a 不等于 b

from calculator import add, subtractdef test_add():   #passassert add(2, 3) == 5
def test_subtract():  #passassert subtract(5, 3) != 1def test_zhen():#failassert 0 
def test_zhen2():#passassert 1def test_jia():#passassert not 0 
def test_jia1():#failassert not 1def test_include():#passassert 1 in [1,2,3]
def test_include2():#failassert 4 in [1,2,3]

执行

命令行执行:

  • pytest .\test_calculator.py 指定执行某文件

  • pytest 文件夹下所有test_* 或者*_test的文件,全部执行

  • pytest test_tt.py::Test::test_case1 pytest路径/文件名::类名::方法名 执行指定文件指定方法

  • pytest test_tt.py::test_case1 pytest路径/文件名::方法名

ide执行:

if __name__ == '__main__':

- pytest.main(['test_tt.py']) 指定文件, 指定执行某文件

- pytest.mian() 没有指定文件,文件夹下所有test_* 或者*_test的文件,全部执行

- pytest.main(['test_tt.py::Test::test_case1']) 指定文件指定类指定方法

- pytest.main(['test_tt.py::test_case1']) 指定文件指定方法

命令行参数执行:

pytest -q 简化控制台的输出

        pytest -q test_calculator.py

pytest -v 输出用例更加详细的执行信息,比如用例所在文件和用例名称

        pytest -v test_calculator.py

pytest -k 执行用例中包含‘关键字’的用例 pytest -v -k "include" 方法名包含include的会被执行

        pytest -k "include" test_calculator.py

pytest -s 输出用例中的调试信息,比如 print 打印信息,如果不加参数则不输出打印信息

        pytest -s test_calculator.py

pytest -m 执行‘标记’的内容,执行特定的测试用例,执行有相同标记的测试用例

        标记方法:方法前 @pytest.mark.run_these 打标run_these

        执行 pytest -m run_these test_calculator.py test_calculator文件中的所有打标run_these的都会被执行

pytest -x执行失败则停止执行,后面的用例不会被执行

        pytest -x test_calculator.py 执行出fail就会break

pytest --maxfail=n执行失败 n 次之后停止执行,n 是执行失败的次数

        pytest --maxfail=3 test_calculator.py 执行,当fail3次的时候,break

pytest --count=n 执行用例 n 次,n=2 就是执行两次

        pytest --count=2 test_calculator.py 执行2次

pytest --lf (last failed)重新运行上次失败的用例,若没有失败的会全部跑

        pytest --lf test_calculator.py 将上次失败的again一遍,没有失败的就all again

pytest --ff (failed first)重新运行所有用例,但首先运行上次失败的用例

        pytest --ff test_calculator.py 所有全部执行一遍,上次失败的优先执行

标记跳过执行

skipif(condition, reason=None) 参数:

condition:跳过的条件,必传参数reason:标注原因,必传参数

使用方法:

@pytest.mark.skipif(condition, reason="xxx") condition 条件为真时跳过

@pytest.mark.skip()

标记预期失败

xfail(condition=None, reason=None, raises=None, run=True, strict=False)

常用参数:

condition:预期失败的条件,必传参数reason:失败的原因,必传参数

使用方法:

@pytest.mark.xfail(condition, reason="xx")condition 为真则标记失败

在某种条件不满足的时候, 预期它是失败的, 就将它标记为预期失败, 若condition 条件不满足则正常执行

预期失败:

  • 没有条件,失败就是xfailed

  • 有条件,条件满足为真,失败就是xfailed

  • 有条件,条件不满足为假,失败就是failed

参数化

方法:

parametrize(argnames, argvalues, indirect=False, ids=None, scope=None)

常用参数:

argnames:参数名

argvalues:参数对应值,类型必须为 list 当参数为一个时格式:[value]

当 参 数 个 数 大 于 一 个 时 , 格 式 为 : [(param_value1,param_value2.....),(param_value1,param_value2 )]

使用方法:

@pytest.mark.parametrize(argnames,argvalues) 参数名,参数值

@pytest.mark.parametrize("a",[3,6])单参数

@pytest.mark.parametrize("a,b",[(1,2),(0,3)])多参数

参数值为 N 个,测试方法就会运行 N 次

标记用例多次执行

首先安装 repeat: pip install pytest-repeat

@pytest.mark.repeat(n)执行当前用例 n 次 然后再往下执行其他用例

标记用例执行顺序

使用:

安 装 pip install pytest-ordering

@pytest.mark.run(order=1)---第1个执行

@pytest.mark.run(order=2)---第2个执行

@pytest.mark.last---最后执行

fixtrue

自定义测试用例预置条件--pytest 精髓fixture

@pytest.fixture()(scope="function",params=None,autouse=False, ids=None, name=None)

调用时被优先执行 预处理或者重复操作scope:被标记方法的作用域

function(default):作用于每个测试方法,每个 test 都运行一次

class:每个 class类执行开始时执行一次 @pytest.fixture()(scope="class",autouse=True)

module:每个 module 的所有 test开始前只执行一次 @pytest.fixture()(scope="module",autouse=True)

session:多个.py 文件的用例的时候, 如果多个用例只需调用一次fixture,那就可以设置为 scope="session"。

params:(list 类型)提供参数数据,供调用标记方法的函数使用

autouse:是否自动运行,默认为 False 不运行,设置为 True 自动运行

若不为 True 则需要调用才会优先执行。

@pytest.fixture()

定义函数,命名不要以 test 开头与用例区分开,fixture 有返回值, 没有返回值默认为 None。用例调用 fixture 返回值,直接就是把 fixture 的函数名称当做变量名称。

生成测试报告

想要生成测试报告,需要先安装 pytest-html

安装命令: pip install pytest-html

  • 命令行生成:pytest --html==路径/文件名.html 执行用例文件.py

    • pytest --html==./report_sample.html test_sample.py html报告

    • pytest --junit-xml==./report_sample.xml test_sample.py xml报告

  • 使用 PyCharm 生成报告

  • if name == "__main__": pytest.main('-s','-v','--html==./report_sample.html','test_samle.py')

http://www.dtcms.com/wzjs/276096.html

相关文章:

  • 昆仑万维做网站怎样做关键词排名优化
  • 高校网站建设招标公告排名
  • 摄像机怎么在自己家网站做直播seo优化快速排名技术
  • 做网站全程指导网络营销和传统营销的区别
  • wordpress网页搭建报名表网站运营推广选择乐云seo
  • 亚马逊跨境电商新手入门seo排名关键词点击
  • 织梦网站怎么安装搜索引擎优化的步骤
  • 陕西营销型网站建设seo外包优化公司
  • 成都麦卡网络做网站开发怎么样哪里有培训网
  • 专业沈阳网站建设搜索引擎入口
  • 织梦电影网站免费模板google关键词排名优化
  • 滨州做网站的谷歌全球营销
  • 长春火车站到长春机场大巴时刻表网站查询系统
  • 今日油价92汽油价关键词优化seo
  • 网站开发总结文档新媒体seo指的是什么
  • 我国建设政府官方门户网站的要求seo推广怎么入门
  • 经过开发建设 网站上线了seo网站推广首页排名
  • 小草网络 网站建设怎样做竞价推广
  • 武汉建站公司哪个好交易链接
  • 织梦做网站的详情产品市场推广方案
  • 化工网站建站模板阿里大数据分析平台
  • 医药网站建设谷歌浏览器app
  • 网站开发游戏程序开发百度大全下载
  • 鹤壁做网站的公司上海sem
  • 自己想做一个网站怎么做的深圳广告公司排名
  • wordpress修改工具百度seo在哪里
  • wordpress 图片 旋转seo专家招聘
  • 哪个网站适合 做红本抵押无锡谷歌推广
  • 网站建设 的类型有哪些方面好的推广方式
  • 淮安网站建设公司sem竞价托管多少钱