Using pytest-json-report 1.4.0 and pytest 6.2.5. There is a bug when using pytest --last-failed --json-report, and no all tests are executed. See the traceback:
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/_pytest/main.py", line 269, in wrap_session
INTERNALERROR> session.exitstatus = doit(config, session) or 0
INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/_pytest/main.py", line 322, in _main
INTERNALERROR> config.hook.pytest_collection(session=session)
INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/pluggy/_hooks.py", line 265, in call
INTERNALERROR> return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/pluggy/_manager.py", line 80, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/pluggy/_callers.py", line 60, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/pluggy/_result.py", line 60, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/pluggy/_callers.py", line 39, in _multicall
INTERNALERROR> res = hook_impl.function(args)
INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/_pytest/main.py", line 333, in pytest_collection
INTERNALERROR> session.perform_collect()
INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/_pytest/main.py", line 637, in perform_collect
INTERNALERROR> hook.pytest_collection_modifyitems(
INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/pluggy/_hooks.py", line 265, in call
INTERNALERROR> return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/pluggy/_manager.py", line 80, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/pluggy/_callers.py", line 55, in _multicall
INTERNALERROR> gen.send(outcome)
INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/_pytest/cacheprovider.py", line 350, in pytest_collection_modifyitems
INTERNALERROR> config.hook.pytest_deselected(items=previously_passed)
INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/pluggy/_hooks.py", line 265, in call
INTERNALERROR> return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/pluggy/_manager.py", line 80, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/pluggy/_callers.py", line 60, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/pluggy/_result.py", line 60, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/pluggy/_callers.py", line 39, in _multicall
INTERNALERROR> res = hook_impl.function(args)
INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/pytest_jsonreport/plugin.py", line 146, in pytest_deselected
INTERNALERROR> item._json_collectitem['deselected'] = True
INTERNALERROR> AttributeError: 'Function' object has no attribute '_json_collectitem'
I fixed it for my use case by protecting the line item._json_collectitem['deselected'] = True with a if hasattr(item, "_json_collectitem"):, but I'm not sure if that's the most appropriate way to do it.
Using pytest-json-report 1.4.0 and pytest 6.2.5. There is a bug when using
pytest --last-failed --json-report
, and no all tests are executed. See the traceback:INTERNALERROR> Traceback (most recent call last): INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/_pytest/main.py", line 269, in wrap_session INTERNALERROR> session.exitstatus = doit(config, session) or 0 INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/_pytest/main.py", line 322, in _main INTERNALERROR> config.hook.pytest_collection(session=session) INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/pluggy/_hooks.py", line 265, in call INTERNALERROR> return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult) INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/pluggy/_manager.py", line 80, in _hookexec INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult) INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/pluggy/_callers.py", line 60, in _multicall INTERNALERROR> return outcome.get_result() INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/pluggy/_result.py", line 60, in get_result INTERNALERROR> raise ex[1].with_traceback(ex[2]) INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/pluggy/_callers.py", line 39, in _multicall INTERNALERROR> res = hook_impl.function(args) INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/_pytest/main.py", line 333, in pytest_collection INTERNALERROR> session.perform_collect() INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/_pytest/main.py", line 637, in perform_collect INTERNALERROR> hook.pytest_collection_modifyitems( INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/pluggy/_hooks.py", line 265, in call INTERNALERROR> return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult) INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/pluggy/_manager.py", line 80, in _hookexec INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult) INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/pluggy/_callers.py", line 55, in _multicall INTERNALERROR> gen.send(outcome) INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/_pytest/cacheprovider.py", line 350, in pytest_collection_modifyitems INTERNALERROR> config.hook.pytest_deselected(items=previously_passed) INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/pluggy/_hooks.py", line 265, in call INTERNALERROR> return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult) INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/pluggy/_manager.py", line 80, in _hookexec INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult) INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/pluggy/_callers.py", line 60, in _multicall INTERNALERROR> return outcome.get_result() INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/pluggy/_result.py", line 60, in get_result INTERNALERROR> raise ex[1].with_traceback(ex[2]) INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/pluggy/_callers.py", line 39, in _multicall INTERNALERROR> res = hook_impl.function(args) INTERNALERROR> File "/opt/app-root/lib64/python3.8/site-packages/pytest_jsonreport/plugin.py", line 146, in pytest_deselected INTERNALERROR> item._json_collectitem['deselected'] = True INTERNALERROR> AttributeError: 'Function' object has no attribute '_json_collectitem'
I fixed it for my use case by protecting the line
item._json_collectitem['deselected'] = True
with aif hasattr(item, "_json_collectitem"):
, but I'm not sure if that's the most appropriate way to do it.