-
-
Notifications
You must be signed in to change notification settings - Fork 288
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
Dynaconf can't find settings file when using pytest #374
Comments
Oh well I found a solution. import os
from dynaconf import Dynaconf
current_directory = os.path.dirname(os.path.realpath(__file__))
settings = Dynaconf(
envvar_prefix="DYNACONF", settings_files=[f"{current_directory}/settings.toml", f"{current_directory}/.secrets.toml"],
) I will keep this issue open for a bit, maybe I can get feedback if this is an appropriate solution or not |
It worked for me. Thanks @trallnag |
worked thanks |
You can also do import os
from dynaconf import Dynaconf
current_directory = os.path.dirname(os.path.realpath(__file__))
settings = Dynaconf(
root_path=current_directory,
envvar_prefix="DYNACONF",
settings_files=["settings.toml", ".secrets.toml"],
) |
Does it mean we need a fix in the documentation so the others who start working with it do not have to spend few ours figuring it out as I did? |
@vbrinza yes that would be great to add that to the docs https://www.dynaconf.com/advanced/#testing |
Ah thanks for the solution!! ... i was 2 hours into debugging |
@rochacbruno please take a look at my PR #819 |
Thank you very much! |
Where do I put settings files / How do I configure Dynaconf so it will work with pytest? Currently I get the following error:
It seems like Dynaconf is looking for the files in the tree the python command was invoked from and not relative the module itself.
Here is how my project structure (simplified) looks like:
My
conf.py
:Thanks in advance
The text was updated successfully, but these errors were encountered: