其他分享
首页 > 其他分享> > pytest.ini文件的创建

pytest.ini文件的创建

作者:互联网

pytest.ini文件的创建

  pytest.ini文件一定要放在项目文件根目录下,并且名称一定要是pytest.ini,否则无法正常识别和使用。    pytest.ini配置文件可以改变pytest一些默认的运行方式,通过设置该配置文件,可以按照用户行为习惯进行改进执行过程,如:用例收集规则,标签,命令行参数等等。  
[pytest]
# 01.可添加多个命令行参数,用空格分隔
addopts = -s -v
 
# 02.搜索文件夹,执行指定文件夹里面的用例
testpaths = ./data
 
# 03.配置搜索测试文件名称,默认是test开头的文件,改成以auto开头,以.py结尾的所有文件
python_files = auto*.py
 
# 04.配置测试搜索的类名,默认是Test开头的类,改成以Auto开头的类
python_classes = Auto_*
 
# 05.配置测试搜索的测试函数名,默认是以test开头的方法/函数,改成以auto开头
python_functions = auto_*
 
# 06.通过标记来执行,标记表达式
markers = 
    slow:
    smoke:
    serial

问题描述:写好test.py文件和pytest.ini文件后,报错:UnicodeDecodeError: 'gbk' codec can't decode byte 0xb0

  1.选择pytest.ini文件   2.点击 file选项   3.选择 File Encoding后   4.选择 GBK (convert to GBK)  

标签:文件,python,创建,pytest,ini,开头,auto
来源: https://www.cnblogs.com/Avicii2018/p/16391336.html