pytest-xdist
pytest-xdist copied to clipboard
Workers did not share option from controller
starting pytest-xdist==1.30.0(Oct 1, 2019) config.option may not be shared between controller and worker processes
sample
pytest.ini
[pytest]
base_url = http://testurl
addopts=-n 1
test_base_url.py
def test_base_url(base_url):
assert base_url == 'http://testurl'
this assert fail when run on xdist workers
[gw0] Python 3.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16:36:42) [MSC v.1929 64 bit (AMD64)]
gw0 [1]
scheduling tests via LoadScheduling
test_base_url.py::test_base_url
[gw0] [100%] FAILED test_base_url.py::test_base_url
test_base_url.py:2 (test_base_url)
base_url = None, request = <FixtureRequest for <Function test_base_url>>
def test_base_url(base_url, request):
> assert base_url == 'http://testurl'
E AssertionError: assert None == 'http://testurl'
test_base_url.py:4: AssertionError
============================== 1 failed in 0.55s ==============================
and pass when run without it pytest.ini
[pytest]
base_url = http://testurl
============================= test session starts =============================
collecting ... collected 1 item
test_base_url.py::test_base_url PASSED [100%]
============================== 1 passed in 0.01s ==============================
pytest-xdist==2.5.0 pytest-base-url==2.0.0 pytest==7.1.2
Is there any workaround here?
Is there any workaround here?
Just found this issue too while studying.
@ltsuda, you can pass url through console argument:
pytest --base-url=http://you_url tests_dir
@ltsuda, you can pass url through console argument:
pytest --base-url=http://you_url tests_dir
wow! pretty cool!
Thanks a lot, the only problem then is using on pytest.ini/pyproject.toml.
Well, I got the idea from your comment and it worked.
In pyproject.toml I use the base url in the addopts field, instead of using the base_url
addopts = "-ra -q --base-url=http://frontend:3001"