测试人社区

pytest rerunfailures 插件与pytest自带的参数化功能冲突

描述:
安装 pytest-rerunfailures-8.0 扩展包使用命令行运行rerun的时候,发现如果测试用例有参数化,就会报错。详细信息如下

代码:


@pytest.mark.parametrize('a,b', [(1, 1), (2, 3)])
def test_rerun(a, b):
    assert a == b

运行命令:

 pytest test_rerun.py --reruns 3 --reruns-delay 1 -vs

报错信息:

test_rerun.py::test_rerun[2-3] RERUN
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/_pytest/main.py", line 191, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/_pytest/main.py", line 247, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pluggy/hooks.py", line 286, in __call__
INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR>   File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pluggy/manager.py", line 93, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pluggy/manager.py", line 84, in <lambda>
INTERNALERROR>     self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
INTERNALERROR>   File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/_pytest/main.py", line 272, in pytest_runtestloop
INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR>   File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pluggy/hooks.py", line 286, in __call__
INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR>   File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pluggy/manager.py", line 93, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pluggy/manager.py", line 84, in <lambda>
INTERNALERROR>     self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
INTERNALERROR>   File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pytest_rerunfailures.py", line 194, in pytest_runtest_protocol
INTERNALERROR>     _remove_cached_results_from_failed_fixtures(item)
INTERNALERROR>   File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pytest_rerunfailures.py", line 135, in _remove_cached_results_from_failed_fixtures
INTERNALERROR>     result, cache_key, err = getattr(fixture_def, cached_result)
INTERNALERROR> TypeError: cannot unpack non-iterable NoneType object