自动化工具 配置 pytest.ini 配置文件后,运行报错 UnicodeDecodeError: 'gbk' codec can't decode byte 0x93 in position 21: illegal multibyte sequence

max · 2018年10月30日 · 最后由 shu307 回复于 2019年05月09日 · 2346 次阅读

新手求助,如题:配置 pytest.ini 配置文件后,运行报错 UnicodeDecodeError: 'gbk' codec can't decode byte 0x93 in position 21: illegal multibyte sequence
总共只有两个文件,一个 pytest.ini 配置文件和一个 test_abc.py 测试代码文件。
命令行运行 pytest test_abc.py 的时候报错 UnicodeDecodeError: 'gbk' codec can't decode byte 0x93 in position 21: illegal multibyte sequence。
删除 pytest.ini 配置文件,命令行运行 pytest -s --html=./report.html test_abc.py 可以正常运行。
请各位大神指教!

就两个简单文件,刚开始学习:
test_abc.py

-- coding:utf-8 –-

import pytest
class Test_ABC:
def setup_class(self):
print("------->setup_class")
def teardown_class(self):
print("------->teardown_class")
def test_a(self):
print("------->test_a")
assert 1
def test_b(self):
print("------->test_b")
assert 0 # 断言失败

pytest.ini

content of pytest.ini

-- coding:utf-8 --

[pytest]
addopts = -s --html=./report.html
python_files = test_.py
python_classes = Test_

python_functions = test_*

共收到 4 条回复 时间 点赞

pytest.ini 的文件编码格式有问题吧,改成 utf-8

max #2 · 2018年10月31日 Author
YueChen 回复

改了还是报错

你好,我遇到了同样的问题,请问解决了吗?

simon14789 回复

把配置文件里的中文全删了就行了

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册