最近学习pytest时,配置pytest.ini后,运行pytest报错,错误如下:
如果你想学习自动化测试,我这边给你推荐一套视频,这个视频可以说是B站百万播放全网第一的自动化测试教程,同时在线人数到达1000人,并且还有笔记可以领取及各路大神技术交流:扣扣群:798478386
B站讲的最详细的Python接口自动化测试实战教程全集(实战最新版)_哔哩哔哩_bilibiliB站讲的最详细的Python接口自动化测试实战教程全集(实战最新版)共计200条视频,包括:1、接口自动化之为什么要做接口自动化、2、接口自动化之request全局观、3、接口自动化之接口实战等,UP主更多精彩视频,请关注UP账号。https://www.bilibili.com/video/BV17p4y1B77x/?spm_id_from=333.337.search-card.all.click
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
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
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,再次运行不在报错。
原因:
目前未知,不知道具体为什么要这样更改,先记录以便后续跟进。