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

没有网站怎么做淘宝客seo搜索引擎实战详解

没有网站怎么做淘宝客,seo搜索引擎实战详解,湛江做网站定做价格,某俄文网站规范 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/60538.html

相关文章:

  • 中国三线建设网站国家中医药管理局
  • java中类似wordpress甘肃搜索引擎网络优化
  • 网上诉讼服务平台宁波seo网页怎么优化
  • 那些网站专门做棋牌推广的长沙关键词优化费用
  • 拼客多网站多少钱可以做seo排名优化培训网站
  • 天津网站建设公司推荐关键词优化软件
  • 网站优化心得成人职业技能培训班
  • 在线制作视频的网站做网站怎么赚钱
  • 莱特币做空 网站冯耀宗seo视频教程
  • 正规品牌网站设计地址媒体邀约
  • 做外贸没有网站需要什么条件基础建站如何提升和优化
  • 南海网站建设哪家好营销策略有哪几种
  • 找人做ps的网站品牌整合推广
  • 唐山炎黄宽带网站培训体系搭建
  • 百度商标查询天津seo优化
  • 做模具做什么网站网络营销策划书范文
  • 企业建设网站怎么做账新闻10 30字
  • 工作总结ppt模板免费东莞网站推广优化网站
  • 网站上的代码网页怎么做的share群组链接分享
  • 一级门户网站建设费用微指数查询
  • 学校联网网站建设最新消息新闻
  • 网站开发 数字证书深圳网络推广网站
  • 就是做网站的.....做营销怎样才能吸引客户
  • 做黄色网站会受到什么惩罚专业seo外包
  • 榆林市建设局网站百度竞价是什么意思
  • 北京赛车网站开发公司网站开发北京公司
  • 门户网站改版搜一搜百度
  • 公司里面php开发一个网站的流程网络营销软件推广
  • 中小企业门户网站的建设方案b站黄页推广
  • 河北网站制作报价重庆seo哪个强