pytest-reportportal 引发测试名称关键错误

问题描述 投票:0回答:1

所以我使用 pytest-reportportal 库来生成 rp launch

但由于某种原因(仅发生在 ubuntu 服务器上,通过 github actions wf 启动) 错误如下

collected 403 items / 325 deselected / 78 selected
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/_pytest/main.py", line 272, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/_pytest/main.py", line 326, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pluggy/_hooks.py", line 501, in __call__
INTERNALERROR>     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR>   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pluggy/_manager.py", line 119, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pluggy/_callers.py", line 181, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pluggy/_result.py", line 99, in get_result
INTERNALERROR>     raise exc.with_traceback(exc.__traceback__)
INTERNALERROR>   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pluggy/_callers.py", line 166, in _multicall
INTERNALERROR>     teardown.throw(outcome._exception)
INTERNALERROR>   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/_pytest/logging.py", line 796, in pytest_runtestloop
INTERNALERROR>     return (yield)  # Run all the tests.
INTERNALERROR>   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pluggy/_callers.py", line 102, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/_pytest/main.py", line 351, in pytest_runtestloop
INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR>   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pluggy/_hooks.py", line 501, in __call__
INTERNALERROR>     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR>   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pluggy/_manager.py", line 119, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pluggy/_callers.py", line 181, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pluggy/_result.py", line 99, in get_result
INTERNALERROR>     raise exc.with_traceback(exc.__traceback__)
INTERNALERROR>   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pluggy/_callers.py", line 166, in _multicall
INTERNALERROR>     teardown.throw(outcome._exception)
INTERNALERROR>   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/_pytest/warnings.py", line 109, in pytest_runtest_protocol
INTERNALERROR>     return (yield)
INTERNALERROR>   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pluggy/_callers.py", line 166, in _multicall
INTERNALERROR>     teardown.throw(outcome._exception)
INTERNALERROR>   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/_pytest/assertion/__init__.py", line 174, in pytest_runtest_protocol
INTERNALERROR>     return (yield)
INTERNALERROR>   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pluggy/_callers.py", line 87, in _multicall
INTERNALERROR>     next(wrapper_gen)  # first yield
INTERNALERROR>   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pytest_reportportal/plugin.py", line 263, in pytest_runtest_protocol
INTERNALERROR>     service.start_pytest_item(item)
INTERNALERROR>   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pytest_reportportal/service.py", line 123, in wrap
INTERNALERROR>     func(*args, **kwargs)
INTERNALERROR>   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pytest_reportportal/service.py", line 713, in start_pytest_item
INTERNALERROR>     self._create_suite_path(test_item)
INTERNALERROR>   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pytest_reportportal/service.py", line 123, in wrap
INTERNALERROR>     func(*args, **kwargs)
INTERNALERROR>   File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pytest_reportportal/service.py", line 462, in _create_suite_path
INTERNALERROR>     path = self._tree_path[item]
INTERNALERROR> KeyError: <Function test_ipsec_domain_address>

这是怎么回事,我真的不知道如何处理这种情况

我对 rp lib 的设置并没有做太多事情

config._inicache["rp_api_key"] = "keymeh
config._inicache["rp_endpoint"] = "url"
config._inicache["rp_project"] = "proj"
config._inicache["rp_launch"] = config.getoption("--run_details")

然后我执行 pytest --reportportal

所以看起来它是随机弹出的,只有当通过标记的类执行测试时(基本上收集了大量测试)才会出现此错误,如果测试是单独执行的,那么一切都很好,但是如果测试是在具有上面有个记号,好像是穿过这个东西嗯

似乎还表明许多测试是通过-v(测试路径)执行的,并且有多个文件具有多个测试类和测试方法

python pytest github-actions reportportal
1个回答
0
投票

这个问题是如何解决的?我也面临同样的问题

© www.soinside.com 2019 - 2024. All rights reserved.