Closed grandfa8 closed 1 year ago
this seems to be intended to set up the details, as far as i understood that works as intended
if hasattr(config, "workerinput"):
return # don't run configure on xdist worker nodes
Why was the base_url not instantiated for the xdist workers configuration? Test runs on workers, not on the controller node, and they don't have this option from ini file.
the options are passed by pytest from the controller to the worker
the configure hook sets the option
starting pytest-xdist==1.30.0(Oct 1, 2019) base_url is not shared between controller and workers.
this changed in https://github.com/pytest-dev/pytest-xdist/blob/30b540cd1f70266fbb88883407a9b85dff0e1cb0/src/xdist/workermanage.py#L244
gets empty option_dict instead option_dict = vars(self.config.option)
Good catch
Closing this as it seems to be out-of-scope for this plugin. Feel free to reopen if you think otherwise.
Hi @RonnyPfannschmidt @BeyondEvil, I have the same question with the issue title. I always get an error on one of my pages as the base_url becomes None when running in parallel. My apologies, just asking for better understanding and best workaround for this issue. TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
def load(self, base_url):
self.page.goto(base_url + self.URL)
#pytest.ini
[pytest]
base_url = http://localhost:3000
It works though when passing the URL as an argument
pytest --base-url http://localhost:3000
There's a workaround if you follow the link to the (still open) issue over at pytest-xdist: https://github.com/pytest-dev/pytest-base-url/issues/34#issuecomment-1198486693. @sayurionishi
Yes, saw this thread when searching for this issue. Thanks @BeyondEvil
This one is a longstanding pytest bug thats hard to unravel
Hi, Thats not critical issue for me but it still interest. Why we don't read base_url param value from pytest.ini when run tests with pytest-xdist plugin? I try replace line https://github.com/pytest-dev/pytest-base-url/blob/master/src/pytest_base_url/plugin.py#L14 by
base_url = config.getoption("base_url") or config.getini("base_url")
and this worked for me