pytest-dev / pytest-dev/pytest-xdist
Cannot pass object to the report (crashitem)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.9k
- Forks
- 287
- Avg merge
- 9h 30m
- Merged PRs (30d)
- 2
Description
I have this issue only when enabling pytest-xdist (1.32.0) using the -n parameter.
After some investigation, I spot the part of our code which raise the error. In our conftest.py file we have something similar to this:
def makereport(self, item: Function, report: TestReport) -> None:
report.foo = {"foo": object()}
We inject additional information within the TestReport object.
Running a test with this will result in:
test_focus.py::TestFocus::test_focus[Marketplace-DISPLAY REDIRECT INTERNAL-WIDGET TOP-desktop-windows 10-chrome]
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "/home/tetienne/git/awesome_project/.venv/lib/python3.7/site-packages/_pytest/main.py", line 191, in wrap_session
INTERNALERROR> session.exitstatus = doit(config, session) or 0
INTERNALERROR> File "/home/tetienne/git/awesome_project/.venv/lib/python3.7/site-packages/_pytest/main.py", line 247, in _main
INTERNALERROR> config.hook.pytest_runtestloop(session=session)
INTERNALERROR> File "/home/tetienne/git/awesome_project/.venv/lib/python3.7/site-packages/pluggy/hooks.py", line 286, in __call__
INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> File "/home/tetienne/git/awesome_project/.venv/lib/python3.7/site-packages/pluggy/manager.py", line 93, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "/home/tetienne/git/awesome_project/.venv/lib/python3.7/site-packages/pluggy/manager.py", line 87, in <lambda>
INTERNALERROR> firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR> File "/home/tetienne/git/awesome_project/.venv/lib/python3.7/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "/home/tetienne/git/awesome_project/.venv/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "/home/tetienne/git/awesome_project/.venv/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "/home/tetienne/git/awesome_project/.venv/lib/python3.7/site-packages/xdist/dsession.py", line 112, in pytest_runtestloop
INTERNALERROR> self.loop_once()
INTERNALERROR> File "/home/tetienne/git/awesome_project/.venv/lib/python3.7/site-packages/xdist/dsession.py", line 135, in loop_once
INTERNALERROR> call(**kwargs)
INTERNALERROR> File "/home/tetienne/git/awesome_project/.venv/lib/python3.7/site-packages/xdist/dsession.py", line 177, in worker_workerfinished
INTERNALERROR> assert not crashitem, (crashitem, node)
INTERNALERROR> AssertionError: ('tests/test_focus.py::TestFocus::test_focus[Marketplace-DISPLAY REDIRECT INTERNAL-WIDGET TOP-desktop-windows 10-chrome]', <WorkerController gw0>)
INTERNALERROR> assert not 'tests/test_focus.py::TestFocus::test_focus[Marketplace-DISPLAY REDIRECT INTERNAL-WIDGET TOP-desktop-windows 10-chrome]'
When passing a string, or an integer, there is no issue.
It's a known behavior?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the conftest.py example with pytest-xdist enabled via -n, then trace how the report is transferred through xdist/dsession.py. Determine the expected handling of an object-valued TestReport attribute and add regression coverage showing that the run no longer crashes while preserving supported report data.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- distributed-systems, testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100