记一次pytest运行报错-UnicodeDecodeError: 'gbk' codec can't decode byte 0xb0 in position 26: illegal multiby

最近学习pytest时,配置pytest.ini后,运行pytest报错,错误如下:

D:\pythonproject\AndroidUIauto\Test_App>pytest
Traceback (most recent call last):
  File "d:\python\python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "d:\python\python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\Python\Python37\Scripts\pytest.exe\__main__.py", line 9, in <module>
  File "d:\python\python37\lib\site-packages\_pytest\config\__init__.py", line 60, in main
    config = _prepareconfig(args, plugins)
  File "d:\python\python37\lib\site-packages\_pytest\config\__init__.py", line 195, in _prepareconfig
    pluginmanager=pluginmanager, args=args
  File "d:\python\python37\lib\site-packages\pluggy\hooks.py", line 289, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "d:\python\python37\lib\site-packages\pluggy\manager.py", line 68, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "d:\python\python37\lib\site-packages\pluggy\manager.py", line 62, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "d:\python\python37\lib\site-packages\pluggy\callers.py", line 203, in _multicall
    gen.send(outcome)
  File "d:\python\python37\lib\site-packages\_pytest\helpconfig.py", line 93, in pytest_cmdline_parse
    config = outcome.get_result()
  File "d:\python\python37\lib\site-packages\pluggy\callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "d:\python\python37\lib\site-packages\pluggy\callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "d:\python\python37\lib\site-packages\_pytest\config\__init__.py", line 654, in pytest_cmdline_parse
    self.parse(args)
  File "d:\python\python37\lib\site-packages\_pytest\config\__init__.py", line 871, in parse
    self._preparse(args, addopts=addopts)
  File "d:\python\python37\lib\site-packages\_pytest\config\__init__.py", line 804, in _preparse
    self._initini(args)
  File "d:\python\python37\lib\site-packages\_pytest\config\__init__.py", line 727, in _initini
    config=self,
  File "d:\python\python37\lib\site-packages\_pytest\config\findpaths.py", line 122, in determine_setup
    rootdir, inifile, inicfg = getcfg([ancestor], config=config)
  File "d:\python\python37\lib\site-packages\_pytest\config\findpaths.py", line 35, in getcfg
    iniconfig = py.iniconfig.IniConfig(p)
  File "d:\python\python37\lib\site-packages\py\_vendored_packages\iniconfig.py", line 54, in __init__
    tokens = self._parse(iter(f))
  File "d:\python\python37\lib\site-packages\py\_vendored_packages\iniconfig.py", line 82, in _parse
    for lineno, line in enumerate(line_iter):
UnicodeDecodeError: 'gbk' codec can't decode byte 0xb0 in position 26: illegal multibyte sequence

解决办法:
更改pytest.ini 文件编码方式为GBK,再次运行不在报错。
在这里插入图片描述在这里插入图片描述
原因:
目前未知,不知道具体为什么要这样更改,先记录以便后续跟进。

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值