-
Notifications
You must be signed in to change notification settings - Fork 341
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
Pytest cannot find settings #58
Comments
For clarity, something like this works without a problem of course: In a file called
Running like this: |
Nevermind... just found the FAQ item that says to install the package locally. Not the prettiest way imho but it's at least a clean workaround :) |
It's in the FAQ (http://pytest-django.readthedocs.org/en/latest/faq.html#i-see-an-error-saying-could-not-import-myproject-settings) but I think it's not clear enough. It's a bug (or maybe a feature?) in py.test. There are couple of ways to solve this:
Personally I think setup.py is the best option IF you are already using it for distributing your code. If not then I'd go with other options. |
The setup.py is my current solution but it's not really the prettiest solution I think. It would be useful if pytest would give a somewhat clearer error in this regard. Perhaps pytest_django should just append the current working directory (i.e. |
Guys, this should be more visible. I was struggling with this a fair bit, when I had the idea to look up closed issues... |
Because this issue does indeed show up in search results, I'd like to add the most simple work-around for afaik:
|
I encountered this issue while having a bogus pytest.ini file:
Removing the quotes fixed it:
|
The current working directory is not in the sys.path so it cannot find my settings file... now I'm wondering what would be the "clean" way to fix this.
I have no problem running other parts of py.test but the pytest_django module cannot find my settings.
My file structure is roughly like this:
Obviously
manage.py
has no problems importing the settings.Py.test is being called like this:
py.test --ds settings
The exception:
What is the proper way to fix this? I know I can set the
PYTHONPATH
variable in my environment but that just seems hacky. Why won't pytest_django import from the current directory as you would expect?The text was updated successfully, but these errors were encountered: