首页 > 其他分享 >pytest -k 参数 从多个py文件中 指定要运行的方法

pytest -k 参数 从多个py文件中 指定要运行的方法

时间:2023-08-03 11:59:41浏览次数:38  
标签:real py print pytest 参数 ex time test def

#D:\pythonProject0726\test_case\test_one.py
import time
def setup_module():
    print('准备测试数据')
def teardown_module():
    print('清理测试数据')
def test_oneone():
    ex=1
    real=1
    time.sleep(3)
    print('1==1')
    assert  ex==real
def test_oneonr():
    ex1=1
    real1=1
    time.sleep(3)
    print('1==1')
    assert  ex1==real1
# D:\pythonProject0726\test_case\test_two.py
import time
def test001():
    print('准备测试数据2')
def teardown_module():
    print('清理测试数据2')
def test_twoy():
    ex=1
    real=2
    time.sleep(3)
    print('1==2')
    assert ex==real
def test_twou():
    ex=1
    real=2
    time.sleep(3)
    print('1==2')
    assert ex==real
# D:\pythonProject0726\test_case\all_test_case.py
import pytest
import xdist

if __name__ == '__main__':
    pytest.main(['-vs'])

 

终端

 pytest -vs test_case -k "test001"                                                     

 

 

 

标签:real,py,print,pytest,参数,ex,time,test,def
From: https://www.cnblogs.com/haha1988/p/17602899.html

相关文章

  • Python 将playwright 脚本打包exe
    1、需要将playwright版本下载,注意:如果不想执行exe出现cmd弹窗,则需要将playwright版本安装为1.29.0。参考:https://blog.csdn.net/tdl320721/article/details/1287372732、下载playwright对应的浏览器驱动,playwrightinstallchrome3、查看python环境目录内的  \Lib\site-......
  • Python开发实例(二)To-Do列表应用:创建一个简单的命令行应用,允许用户添加、删除和查看待
    defprint_todo_list(todo_list):ifnottodo_list:print("待办事项列表为空!")else:print("待办事项列表:")forindex,todoinenumerate(todo_list,1):print(f"{index}.{todo}")defadd_todo(todo_......
  • 【python_4】基础语法:字面量和注释!
    1.字面量的含义字面量:在代码中,被写下来的固定的值,称之为字面量。2.常见的字面量类型类型描述说明数字Number支持:整数int浮点数float复数complex布尔bool整数int,如10,-10浮点数float,如13.14,-13.14复数complex,如4+3j布尔bool,表达现实生活中的逻辑,即真和假,True表示真,False表示假。True......
  • python使用mqtt
    一、安装mqtt服务器安装对应的软件:https://www.emqx.io/zh/downloads推荐使用docker安装默认账号和密码:admin、public 二、编写代码消息发布程序importtimeimportjsonimportpsutilimportrandomfrompaho.mqttimportclientasmqtt_clientbroker='127.0.0.1......
  • pytest 中添加线程
    #D:\pythonProject0726\test_case\test_one.pyimporttimedefsetup_module():print('准备测试数据')defteardown_module():print('清理测试数据')deftest_one():ex=1real=1time.sleep(3)print('1==1')assert......
  • numpy
    concatenate(vstack列方向和hstack行方向)numpy.concatenate((a1,a2,...),axis=0) 其中:a1,a2,....:待合并的数组axis:沿着数组合并的维度,默认为0(对于二维数组来说,默认沿着行的方向进行合并)这里需要注意a1,a2,...待合并的数组除了待合并的维度,其余维度上的值必......
  • 【银河麒麟】Python3.9的安装
    国产银河麒麟原装python3.5,版本较为落后,经过多次尝试+百度各种方法,现将安装python3.9的过程记录如下:1.安装依赖环境(打开终端)sudoaptupdatesudoapt-getinstallbuild-essentialzlib1g-devlibbz2-1.0libssl-devlibncurses5-devlibsqlite3-devlibreadline-devtk-de......
  • 【快应用】同时传递事件对象和自定义参数 ,无法正确接收事件对象
     【关键词】事件绑定、自定义参数、事件对象【问题背景】在快应用中采用如下方式绑定组件的事件方法,同时传递事件对象和自定义参数,发现回调方法中没有正确接收到事件对象。问题代码如下:<template><!--Onlyonerootnodeisallowedintemplate.--><divclass="contain......
  • C++11可变模版参数妙用
    //参考:https://blog.csdn.net/wmy19890322/article/details/121427697点击查看代码//创建对象template<typenameT,typename...Args>T*CreateInstance(Args...args){ returnnewT(std::forward<Args>(args)...);}//可变参数模版实现泛化的delegatetemplate<typena......
  • python教程 入门学习笔记 第5天 format函数拼接 两种打印方法 转义字符
    2)format函数拼接#format函数拼接s1="统计={0}{1}{2}".format("张三","工资",3400)#占位符{}中可以填写数字编号print(s1)s2="统计={}{}{}".format("李四","工资",4500)#用占位符{}拼接,占位符要与字符串数量一致print(s2)s3="统计={a}{b}{c}".forma......