Skip to content

Setting a variable from the child conftest to the upper conftest #3363

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

Closed
redsox10 opened this issue Apr 3, 2018 · 3 comments
Closed

Setting a variable from the child conftest to the upper conftest #3363

redsox10 opened this issue Apr 3, 2018 · 3 comments
Labels
status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity type: question general question, might be closed after 2 weeks of inactivity

Comments

@redsox10
Copy link

redsox10 commented Apr 3, 2018

Hey, guys. So I have this scenario where I would really appreciate some help.

Here is a mock example:

├──parent
│  ├──test1dir
│  │  ├  conftest.py
│  │  ├  test_1.py
│  ├  conftest.py
# parent/test1dir/conftest.py
def pytest_runtest_setup(item):
    do_something(item, local_fixt())
    # --> somehow set global_var in parent conftest <--

@pytest.fixture(scope="session")
def local_fixt():
    return 123
# parent/test1dir/conftest.py
@pytest.fixture(scope="session") # same for function scoped fixtures
def session_fixt(local_fixt)
    do_something(global_var)
    do_something(local_fixt)

Reason why I don't move pytest_runtest_setup in parent conftest is that I need it to access local_fixt() and it isn't able to do that from the upper conftest file as it would solve this issue.

@pytestbot pytestbot added the type: question general question, might be closed after 2 weeks of inactivity label Apr 3, 2018
@pytestbot
Copy link
Contributor

GitMate.io thinks possibly related issues are #430 (Config variable to set locations to try for conftest.py files), #1176 (conftest undocumented), #2583 (Set an environment variable with current test), #3272 (Question: How can I import some variable from parent conftest.py when I have another conftest.py in local directory.), and #294 (Fixture is not overriden in the child conftest.py when running individual test file).

@RonnyPfannschmidt
Copy link
Member

fixtures are not available that way, please explain the actual use-case

@RonnyPfannschmidt RonnyPfannschmidt added the status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity label Apr 7, 2018
@nicoddemus
Copy link
Member

Closing as this has not seen activity in awhile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity type: question general question, might be closed after 2 weeks of inactivity
Projects
None yet
Development

No branches or pull requests

4 participants