Loading

自动化过程遇到的问题

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:\Forudesigns201\uitestcase\report\2019_11_25_23_55_35\report.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:\Forudesigns201\uitestcase\report\2019_11_26_00_42_05\report.html --self-contained-html --reruns 3
inifile: None
rootdir: E:\Forudesigns201\uitestcase

 

 

 

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:\Users\owolf\Desktop\1.py
C:\Users\owolf\Desktop
C:\Users\owolf\Desktop\1.py

 


 

posted @ 2019-11-25 14:05  Tester-Dolores  阅读(320)  评论(0编辑  收藏  举报