Skip to content

Having all options from all conftest.py for all collected tests #3212

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
bechaos opened this issue Feb 13, 2018 · 2 comments
Closed

Having all options from all conftest.py for all collected tests #3212

bechaos opened this issue Feb 13, 2018 · 2 comments
Labels
topic: config related to config handling, argument parsing and config file type: question general question, might be closed after 2 weeks of inactivity

Comments

@bechaos
Copy link

bechaos commented Feb 13, 2018

Hello.
In directory structure:

/conftest.py
/tests_A/conftest.py
/tests_A/tests_A.py
/tests_B/conftest.py
/tests_B/tests_B.py

i have "pytest_addoption" hook in /tests_A/conftest.py and /tests_B/conftest.py with options which are related to tests in tests_A.py and tests_B.py, and in /conftest.py options common for both.

If i call ptyest from /tests_A/ or /tests_B/ i have options available for those tests. However if i call pytest from / specific options are unrecognized. Im aware that i could write all options in /conftest.py. but due clean code, I'd rather have it separated.

I there a way to achieve this?

Thank you for your time.

@nicoddemus
Copy link
Member

@bechaos unfortunately due to how pytest_addoption works the recommended way is to declare all options in the root conftest.py level, there's a note explaining that in the docs for pytest_addoption.

@nicoddemus nicoddemus added type: question general question, might be closed after 2 weeks of inactivity topic: config related to config handling, argument parsing and config file labels Feb 26, 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
topic: config related to config handling, argument parsing and config file type: question general question, might be closed after 2 weeks of inactivity
Projects
None yet
Development

No branches or pull requests

2 participants