dynaconf
dynaconf copied to clipboard
[RFC] Add FORCE_SETTINGS_FILES to LazySettings.configure() for pytest
I am using DynaConf for loading settings for CLI scripts which are widely distributed. The TOML settings files are located in common configuration paths in the user space such as ~/.config/cli/config.toml
or ~/Library/Application Support/cli/config.toml
.
It is confusing to ask end-users to place their values under a an environment header such as [default]
. End users will never need different environments. However, when running pytest to test my CLI there is no easy way to override the values of the settings_files
configuration option.
Similar to how you can add settings.configure(FORCE_ENV_FOR_DYNACONF="testing")
to force an environment to be used in testing, it would be great to have SETTINGS.configure(FORCE_SETTINGS_FILES=[path/to/settings.toml])
to override the files that are loaded. This would allow easy creation of multiple configuration files to be used in integration tests.
Maybe there is an easier way to do this, but I haven't found one yet.