Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workers did not share option from controller #800

Open
phnmn opened this issue Jul 27, 2022 · 4 comments · May be fixed by #799
Open

Workers did not share option from controller #800

phnmn opened this issue Jul 27, 2022 · 4 comments · May be fixed by #799

Comments

@phnmn
Copy link

phnmn commented Jul 27, 2022

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

@MaksimKravchuk
Copy link

Is there any workaround here?

@ltsuda
Copy link

ltsuda commented Feb 8, 2023

Is there any workaround here?

Just found this issue too while studying.

@phnmn
Copy link
Author

phnmn commented Feb 8, 2023

@ltsuda, you can pass url through console argument:
pytest --base-url=http://you_url tests_dir

@ltsuda
Copy link

ltsuda commented Feb 9, 2023

@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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants