Closed AmirYa412 closed 8 months ago
As mentioned in https://github.com/pytest-dev/pytest-bdd/issues/679#issuecomment-1995672527, pytest-bdd works fine with pytest-xdist and it's tested against it.
I even tried reproducing the issue installing py3.7, pytest==7.4.3, pytest-bdd==6.1.1, pytest-xdist==3.5.0, but I don't see any error.
If it doesn't work for you, please first try to upgrade your dependencies (as you seem to be using outdated versions of pytest-bdd, pytest and pytest-xdist). If it still doesn't work, please provide a MCVE so that I can debug the issue.
Closing this unless more info is provided.
Thanks for your reply. @youtux
Posted the issue on pytest-xdist
git, and the devs there said the issue lies with pytest-bdd
:
https://github.com/pytest-dev/pytest-xdist/issues/1038
I can reproduce the issue on my demo project, https://github.com/AmirYa412/Pytest-BDD-Project
Note: Need to replace in requirements.txt file from pytest-parallel
to pytest-xdist==3.5.0
.
Simply installed dependencies on a venv, and ran pytest -n 2
command reproduced the issue for me on MacOS Sonoma.
Dependencies:
pytest==7.4.3
pytest-bdd==6.1.1
pytest-bdd-html==0.1.14a0
pytest-html==3.2.0
pytest-metadata==3.0.0
pytest-xdist==3.5.0
requests==2.31.0
urllib3==1.26.12
Sadly in my company, we are running on Python 3.7 for now, so upgrading to latest pytest-bdd
version is currently impossible. I will try running my project with 3.11 and update in new comment.
Here is the full error log:
========================================================================================================= test session starts ==========================================================================================================
platform darwin -- Python 3.7.3, pytest-7.4.3, pluggy-1.2.0
rootdir: /Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project
configfile: pytest.ini
testpaths: steps
plugins: html-3.2.0, metadata-3.0.0, xdist-3.5.0, bdd-html-0.1.14a0, bdd-6.1.1
2 workers [10 items]
INTERNALERROR> def worker_internal_error(self, node, formatted_error):
INTERNALERROR> """
INTERNALERROR> pytest_internalerror() was called on the worker.
INTERNALERROR>
INTERNALERROR> pytest_internalerror() arguments are an excinfo and an excrepr, which can't
INTERNALERROR> be serialized, so we go with a poor man's solution of raising an exception
INTERNALERROR> here ourselves using the formatted message.
INTERNALERROR> """
INTERNALERROR> self._active_nodes.remove(node)
INTERNALERROR> try:
INTERNALERROR> > assert False, formatted_error
INTERNALERROR> E AssertionError: Traceback (most recent call last):
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/execnet/gateway_base.py", line 1498, in _save
INTERNALERROR> E dispatch = self._dispatch[tp]
INTERNALERROR> E KeyError: <class 'pytest_bdd.parser.Step'>
INTERNALERROR> E
INTERNALERROR> E During handling of the above exception, another exception occurred:
INTERNALERROR> E
INTERNALERROR> E Traceback (most recent call last):
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/_pytest/main.py", line 271, in wrap_session
INTERNALERROR> E session.exitstatus = doit(config, session) or 0
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/_pytest/main.py", line 325, in _main
INTERNALERROR> E config.hook.pytest_runtestloop(session=session)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/pluggy/_hooks.py", line 433, in __call__
INTERNALERROR> E return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/pluggy/_manager.py", line 112, in _hookexec
INTERNALERROR> E return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/pluggy/_callers.py", line 155, in _multicall
INTERNALERROR> E return outcome.get_result()
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/pluggy/_result.py", line 108, in get_result
INTERNALERROR> E raise exc.with_traceback(exc.__traceback__)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/pluggy/_callers.py", line 80, in _multicall
INTERNALERROR> E res = hook_impl.function(*args)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/xdist/remote.py", line 157, in pytest_runtestloop
INTERNALERROR> E self.run_one_test()
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/xdist/remote.py", line 174, in run_one_test
INTERNALERROR> E self.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/pluggy/_hooks.py", line 433, in __call__
INTERNALERROR> E return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/pluggy/_manager.py", line 112, in _hookexec
INTERNALERROR> E return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/pluggy/_callers.py", line 155, in _multicall
INTERNALERROR> E return outcome.get_result()
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/pluggy/_result.py", line 108, in get_result
INTERNALERROR> E raise exc.with_traceback(exc.__traceback__)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/pluggy/_callers.py", line 80, in _multicall
INTERNALERROR> E res = hook_impl.function(*args)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/_pytest/runner.py", line 114, in pytest_runtest_protocol
INTERNALERROR> E runtestprotocol(item, nextitem=nextitem)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/_pytest/runner.py", line 133, in runtestprotocol
INTERNALERROR> E reports.append(call_and_report(item, "call", log))
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/_pytest/runner.py", line 226, in call_and_report
INTERNALERROR> E hook.pytest_runtest_logreport(report=report)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/pluggy/_hooks.py", line 433, in __call__
INTERNALERROR> E return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/pluggy/_manager.py", line 112, in _hookexec
INTERNALERROR> E return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/pluggy/_callers.py", line 116, in _multicall
INTERNALERROR> E raise exception.with_traceback(exception.__traceback__)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/pluggy/_callers.py", line 80, in _multicall
INTERNALERROR> E res = hook_impl.function(*args)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/xdist/remote.py", line 227, in pytest_runtest_logreport
INTERNALERROR> E self.sendevent("testreport", data=data)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/xdist/remote.py", line 87, in sendevent
INTERNALERROR> E self.channel.send((name, kwargs))
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/execnet/gateway_base.py", line 811, in send
INTERNALERROR> E self.gateway._send(Message.CHANNEL_DATA, self.id, dumps_internal(item))
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/execnet/gateway_base.py", line 1469, in dumps_internal
INTERNALERROR> E return _Serializer().save(obj)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/execnet/gateway_base.py", line 1487, in save
INTERNALERROR> E self._save(obj)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/execnet/gateway_base.py", line 1505, in _save
INTERNALERROR> E dispatch(self, obj)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/execnet/gateway_base.py", line 1580, in save_tuple
INTERNALERROR> E self._save(item)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/execnet/gateway_base.py", line 1505, in _save
INTERNALERROR> E dispatch(self, obj)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/execnet/gateway_base.py", line 1576, in save_dict
INTERNALERROR> E self._write_setitem(key, value)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/execnet/gateway_base.py", line 1570, in _write_setitem
INTERNALERROR> E self._save(value)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/execnet/gateway_base.py", line 1505, in _save
INTERNALERROR> E dispatch(self, obj)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/execnet/gateway_base.py", line 1576, in save_dict
INTERNALERROR> E self._write_setitem(key, value)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/execnet/gateway_base.py", line 1570, in _write_setitem
INTERNALERROR> E self._save(value)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/execnet/gateway_base.py", line 1505, in _save
INTERNALERROR> E dispatch(self, obj)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/execnet/gateway_base.py", line 1566, in save_list
INTERNALERROR> E self._write_setitem(i, item)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/execnet/gateway_base.py", line 1570, in _write_setitem
INTERNALERROR> E self._save(value)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/execnet/gateway_base.py", line 1505, in _save
INTERNALERROR> E dispatch(self, obj)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/execnet/gateway_base.py", line 1580, in save_tuple
INTERNALERROR> E self._save(item)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/execnet/gateway_base.py", line 1505, in _save
INTERNALERROR> E dispatch(self, obj)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/execnet/gateway_base.py", line 1576, in save_dict
INTERNALERROR> E self._write_setitem(key, value)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/execnet/gateway_base.py", line 1570, in _write_setitem
INTERNALERROR> E self._save(value)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/execnet/gateway_base.py", line 1505, in _save
INTERNALERROR> E dispatch(self, obj)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/execnet/gateway_base.py", line 1566, in save_list
INTERNALERROR> E self._write_setitem(i, item)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/execnet/gateway_base.py", line 1570, in _write_setitem
INTERNALERROR> E self._save(value)
INTERNALERROR> E File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/execnet/gateway_base.py", line 1503, in _save
INTERNALERROR> E raise DumpError(f"can't serialize {tp}")
INTERNALERROR> E execnet.gateway_base.DumpError: can't serialize <class 'pytest_bdd.parser.Step'>
INTERNALERROR> E assert False
INTERNALERROR>
INTERNALERROR> venv-bdd/lib/python3.7/site-packages/xdist/dsession.py:200: AssertionError
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/_pytest/main.py", line 271, in wrap_session
INTERNALERROR> session.exitstatus = doit(config, session) or 0
INTERNALERROR> File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/_pytest/main.py", line 325, in _main
INTERNALERROR> config.hook.pytest_runtestloop(session=session)
INTERNALERROR> File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/pluggy/_hooks.py", line 433, in __call__
INTERNALERROR> return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
INTERNALERROR> File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/pluggy/_manager.py", line 112, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/pluggy/_callers.py", line 155, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/pluggy/_result.py", line 108, in get_result
INTERNALERROR> raise exc.with_traceback(exc.__traceback__)
INTERNALERROR> File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/pluggy/_callers.py", line 80, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/xdist/dsession.py", line 123, in pytest_runtestloop
INTERNALERROR> self.loop_once()
INTERNALERROR> File "/Users/aaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/xdist/dsession.py", line 148, in loop_once
INTERNALERROR> call(**kwargs)
INTERNALERROR> File "/Users/aaaaaa/Desktop/Projects/personal_projects/Pytest-BDD-Project/venv-bdd/lib/python3.7/site-packages/xdist/dsession.py", line 187, in worker_workerfinished
INTERNALERROR> assert not crashitem, (crashitem, node)
INTERNALERROR> AssertionError: ('steps/comments_steps/test_comments.py::test_publish_new_comment_on_random_post[Foo Boy-foo@gmail.com-Body t3xt w!th sp3ci@l ch@r@cters]', <WorkerController gw1>)
INTERNALERROR> assert not 'steps/comments_steps/test_comments.py::test_publish_new_comment_on_random_post[Foo Boy-foo@gmail.com-Body t3xt w!th sp3ci@l ch@r@cters]'
Try removing the pytest-bdd-html dependency, that's the one causing the error.
@youtux You were right! It was pytest-bdd-html
after all! I will raise in their repo.
Thanks a lot for your effort.
I am using in my pytest-bdd project(Python 3.7.3 | MacOS Sonoma) the following packages:
when trying to run my pytest-bdd project in parallel using pytest-xdistl I get the following error:
Any workaround suggestion is appreciated, currently using pytest-parallel as I have no choice but it has many limitations and it seems to be no longer supported by it's devs.