I have a remote script that needs to be executed by xdist, which I am giving through the hook pytest_xdist_getremotemodule(), I am performing some collection changes, that are common to all nodes through pytest_collection_modifyitems(), but during the runtestloop the worker fails with AssertionError
platform darwin -- Python 3.9.1, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 -- /usr/local/opt/python@3.9/bin/python3.9
cachedir: .pytest_cache
rootdir: /Users/akhileshr/Projects/pytest_test, configfile: pytest.ini
plugins: xdist-2.2.1, easyread-0.1.0, forked-1.3.0
[gw0] darwin Python 3.9.1 cwd: /Users/akhileshr/Projects/pytest_test
[gw1] darwin Python 3.9.1 cwd: /Users/akhileshr/Projects/pytest_test
[gw0] Python 3.9.1 (default, Jan 8 2021, 17:17:43) -- [Clang 12.0.0 (clang-1200.0.32.28)]
[gw1] Python 3.9.1 (default, Jan 8 2021, 17:17:43) -- [Clang 12.0.0 (clang-1200.0.32.28)]
gw0 [6] / gw1 [6]
scheduling tests via LoadScheduling
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "/usr/local/lib/python3.9/site-packages/_pytest/main.py", line 269, in wrap_session
INTERNALERROR> session.exitstatus = doit(config, session) or 0
INTERNALERROR> File "/usr/local/lib/python3.9/site-packages/_pytest/main.py", line 323, in _main
INTERNALERROR> config.hook.pytest_runtestloop(session=session)
INTERNALERROR> File "/usr/local/lib/python3.9/site-packages/pluggy/hooks.py", line 286, in __call__
INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> File "/usr/local/lib/python3.9/site-packages/pluggy/manager.py", line 93, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "/usr/local/lib/python3.9/site-packages/pluggy/manager.py", line 84, in <lambda>
INTERNALERROR> self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
INTERNALERROR> File "/usr/local/lib/python3.9/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "/usr/local/lib/python3.9/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "/usr/local/lib/python3.9/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "/usr/local/lib/python3.9/site-packages/xdist/dsession.py", line 112, in pytest_runtestloop
INTERNALERROR> self.loop_once()
INTERNALERROR> File "/usr/local/lib/python3.9/site-packages/xdist/dsession.py", line 135, in loop_once
INTERNALERROR> call(**kwargs)
INTERNALERROR> File "/Users/akhileshr/Projects/pytest_test/pytest_bypass.py", line 62, in worker_workerfinished
INTERNALERROR> assert not crashitem, (crashitem, node)
INTERNALERROR> AssertionError: ('dum_py.py::test_pytestDum', <WorkerController gw1>)
The testscript has a simple assertion statement 1==1
When I remove the pytest_collection_modifyitems() function from remote script, the program works without any issue. Can some one help me understand the reason for this issue?