Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working when using --last-failed #69

Closed
guillp opened this issue Sep 24, 2021 · 0 comments · Fixed by #70
Closed

Not working when using --last-failed #69

guillp opened this issue Sep 24, 2021 · 0 comments · Fixed by #70

Comments

@guillp
Copy link

guillp commented Sep 24, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant