• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

pytest框架提示“no tests ran in 0.01s“

武飞扬头像
无我不欢
帮助1

  1.  
    import requests
  2.  
    import pytest
  3.  
     
  4.  
     
  5.  
     
  6.  
    class TestSendRequest:
  7.  
     
  8.  
     
  9.  
    def test_get_login(self):
  10.  
    url = "https://cXX.com/crm/account_center/login?queryFrom=query"
  11.  
     
  12.  
    headers ={
  13.  
    "Accept":"application/json",
  14.  
    "Cache-Control":"no-cache",
  15.  
    "Connection":"keep-alive",
  16.  
    "Content-Type":"application/json;charset=UTF-8",
  17.  
    "x-auth-token":"95c976d-0fa0-482d-9848-ab067abe5cde"
  18.  
    }
  19.  
    data = {
  20.  
    "userName": "aa",
  21.  
    "password": "bb"
  22.  
    }
  23.  
    rep =requests.request('post',url=url,headers=headers,json=data)
  24.  
    print(rep.text)
  25.  
     
  26.  
     
  27.  
     
  28.  
    def test_get_xyt(self):
  29.  
    url2="https://XX.com/srm/enterprise_customer/enterprise_account_list?currentPage=1&pageSize=10&sellerEnterpriseId=8294&queryFrom=query"
  30.  
    rep2=requests.request('get',url=url2)
  31.  
    print(rep2.text)
  32.  
    if __name__ == '__main__':
  33.  
    pytest.main()
学新通

 pytest.ini

  1.  
    [pytest]
  2.  
    #命令
  3.  
    addopts = -vs -p no:warnings
  4.  
    #路径
  5.  
    testpaths= ./testcases
  6.  
    #文件规则
  7.  
    python_files = test_*.py
  8.  
    #类的规则
  9.  
    pytest_classes = Test*
  10.  
    #方法的规则
  11.  
    pytest_function = test_*
  12.  
    #对用例进行分组
  13.  
    markers =
  14.  
    smoke:maoyan

然后报错

学新通

后来我将

testpaths= ./testcases

改成了

testpath= ./testcases

就可以了

有没有大神知道为什么??

  1.  
    [pytest]
  2.  
    #命令
  3.  
    addopts = -vs -p no:warnings
  4.  
    #路径
  5.  
    testpath= ./testcases
  6.  
    #文件规则
  7.  
    python_files = test_*.py
  8.  
    #类的规则
  9.  
    pytest_classes = Test*
  10.  
    #方法的规则
  11.  
    pytest_function = test_*
  12.  
    #对用例进行分组
  13.  
    markers =
  14.  
    smoke:maoyan

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhggahij
系列文章
更多 icon
同类精品
更多 icon
继续加载