-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
module has no attribute config
when accessing pytest.config
in conftest
#1688
Comments
Thanks for the report! While I agree this should be fixed, keep in mind that using For your use case I would recommend using a fixture instead: import pytest
@pytest.fixture(scope='session')
def data_dir(pytestconfig):
return pytestconfig.rootdir.join('some/dir') |
Thanks for the fast response! Is there a way to automatically use a fixture before any tests are run? Really that's what I'm trying to fake. |
Sure! You can use an autouse session-scoped fixture:
See the fixture documentation for details. |
Interesting! The documentation seemed, too me, to suggest that autoused fixtures would be run once for every function, no matter what their |
I wouldn't have even attempted what I did to cause pytest-dev#1688 if this had been there.
Nice, thanks for the PR! 😁 |
I am doing some one-time initialization in a
conftest.py
that I would like to have relative to the rootdir. Theoretically I should be able to do:And indeed, this usually succeeds:
But when actually running with a fully-specified path this fails:
Trying to reproduce this, I'm unable to get it to succeed in any way:
Gives me the same error:
No combination of options seems to be able to make this work. I'm no longer sure that this is supposed to work, but it seems weird that it works for me in my previously most-common use-case.
pip list
of the virtual environment you are usingpy.test 2.7.2, 2.8.7, 2.9.1
OSX 10.9.5, Darwin 13.4.0
The text was updated successfully, but these errors were encountered: