关于python3.10的一些问题
在执行pytest的时候,报错:
D:\Users\User\Desktop\pytest_practice_V5\vvenv\Scripts\python.exe D:/Users/User/Desktop/pytest_practice_V5/main_run.py
Traceback (most recent call last):
File "D:\Users\User\Desktop\pytest_practice_V5\main_run.py", line 10, in <module>
run()
File "D:\Users\User\Desktop\pytest_practice_V5\main_run.py", line 4, in run
pytest.main(['-s', '-v', './test_case/test_shop_pom_V2.py',
File "D:\Users\User\Desktop\pytest_practice_V5\vvenv\lib\site-packages\_pytest\config\__init__.py", line 143, in main
config = _prepareconfig(args, plugins)
File "D:\Users\User\Desktop\pytest_practice_V5\vvenv\lib\site-packages\_pytest\config\__init__.py", line 318, in _prepareconfig
config = pluginmanager.hook.pytest_cmdline_parse(
File "D:\Users\User\Desktop\pytest_practice_V5\vvenv\lib\site-packages\pluggy\hooks.py", line 286, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "D:\Users\User\Desktop\pytest_practice_V5\vvenv\lib\site-packages\pluggy\manager.py", line 93, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "D:\Users\User\Desktop\pytest_practice_V5\vvenv\lib\site-packages\pluggy\manager.py", line 84, in <lambda>
self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
File "D:\Users\User\Desktop\pytest_practice_V5\vvenv\lib\site-packages\pluggy\callers.py", line 203, in _multicall
gen.send(outcome)
File "D:\Users\User\Desktop\pytest_practice_V5\vvenv\lib\site-packages\_pytest\helpconfig.py", line 100, in pytest_cmdline_parse
config = outcome.get_result() # type: Config
File "D:\Users\User\Desktop\pytest_practice_V5\vvenv\lib\site-packages\pluggy\callers.py", line 80, in get_result
raise ex[1].with_traceback(ex[2])
File "D:\Users\User\Desktop\pytest_practice_V5\vvenv\lib\site-packages\pluggy\callers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "D:\Users\User\Desktop\pytest_practice_V5\vvenv\lib\site-packages\_pytest\config\__init__.py", line 1003, in pytest_cmdline_parse
self.parse(args)
File "D:\Users\User\Desktop\pytest_practice_V5\vvenv\lib\site-packages\_pytest\config\__init__.py", line 1280, in parse
self._preparse(args, addopts=addopts)
File "D:\Users\User\Desktop\pytest_practice_V5\vvenv\lib\site-packages\_pytest\config\__init__.py", line 1172, in _preparse
self.pluginmanager.load_setuptools_entrypoints("pytest11")
File "D:\Users\User\Desktop\pytest_practice_V5\vvenv\lib\site-packages\pluggy\manager.py", line 299, in load_setuptools_entrypoints
plugin = ep.load()
File "D:\Program Files\python312\lib\importlib\metadata.py", line 77, in load
module = import_module(match.group('module'))
File "D:\Program Files\python312\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "D:\Users\User\Desktop\pytest_practice_V5\vvenv\lib\site-packages\_pytest\assertion\rewrite.py", line 162, in exec_module
source_stat, co = _rewrite_test(fn, self.config)
File "D:\Users\User\Desktop\pytest_practice_V5\vvenv\lib\site-packages\_pytest\assertion\rewrite.py", line 359, in _rewrite_test
co = compile(tree, fn_, "exec", dont_inherit=True)
TypeError: required field "lineno" missing from alias
Process finished with exit code 1
运行代码截图:
报错截图:
报错底层源码:
运行环境:
python3.10.0-3.10.2,
pytest6.1.2
selenium3.141.0
pytest-rerunfailures9.1.1
执行环境截图:
解决方案:
回滚到python3.9方可正常执行