zoukankan      html  css  js  c++  java
  • 自动化过程遇到的问题

    1.问题:pytest运行报错,AttributeError: 'Function' object has no attribute 'get_marker解决方法

    解决方法: 更新pytest_remotedata 或 pytest

    2.__file__ 是什么?

    当前文件路径

    3.使用pytest框架无法执行用例

    报错1:缺少pytest-html库

    详细: 

    2019-11-25 23:55:35,843 - INFO - 回归模式,开始执行✈✈!
    usage: run_test.py [options] [file_or_dir] [file_or_dir] [...]
    run_test.py: error: unrecognized arguments: --html=E:Forudesigns201uitestcase eport2019_11_25_23_55_35 eport.html --self-contained-html --reruns 3
    inifile: None
    rootdir: E:Forudesigns201

    解决方法:      pip install pytest-html      

    一直报错,也有要求pytest是最新版本,因此先安装pytest:   pip install pytest

    报错2:然而在安装pytest一直安装失败!!!报错: socket.timeout: The read operation timed out

    找到解决方案:增加超时等待时间

    pip --default-timeout=100 install pytest-5.3.0-py3-none-any.whl

    安装好pytest了之后就可以安装pytest-html和pytest-rerunfailures了

    参考:https://www.cnblogs.com/xiaoduc-org/p/5958973.html

    报错3:缺少pytest-rerunfailures库

    2019-11-26 00:42:05,730 - INFO - 回归模式,开始执行✈✈!
    usage: run_test.py [options] [file_or_dir] [file_or_dir] [...]
    run_test.py: error: unrecognized arguments: --html=E:Forudesigns201uitestcase eport2019_11_26_00_42_05 eport.html --self-contained-html --reruns 3
    inifile: None
    rootdir: E:Forudesigns201uitestcase

    4.os.path.dirname和os.path.abspath 的区别

    source: https://www.jianshu.com/p/a2e603571eba

    import os
    #os.path.dirname(__file__)返回的是.py文件的目录
    path1=os.path.dirname(__file__)
    print(path1)
    
    #os.path.abspath(__file__)返回的是.py文件的绝对路径(完整路径)
    path2=os.path.abspath(__file__)
    print(path2)
    
    #组合使用
    path3=os.path.dirname(os.path.abspath(__file__))
    print(path3)
    
    #os.path.join()拼接路径
    path4= os.path.join(os.path.dirname(os.path.abspath(__file__)),'1.py')
    print(path4)

    执行结果如下:
    C:/Users/owolf/Desktop
    C:UsersowolfDesktop1.py
    C:UsersowolfDesktop
    C:UsersowolfDesktop1.py
    
    
    
  • 相关阅读:
    Mybatis学习01:利用mybatis查询数据库
    SpringBoot_登录注册
    python抓取中科院大学招聘
    centos7设置固定IP
    PIL给图片加水印
    You can ignore those files in your build.gradle
    mysql事件执行时间
    wampserver2.5域名解析错误问题
    Mysql错误消息 语言设置
    js控制select多选
  • 原文地址:https://www.cnblogs.com/Tester_Dolores/p/11927267.html
Copyright © 2011-2022 走看看