Hi. I need to override the environment for settings in conftest.py. As I found I can do it by adding:
from dynaconf import settings
@pytest.fixture(scope="session", autouse=True)
def set_test_settings():
settings.configure(FORCE_ENV_FOR_DYNACONF="testing")
but in my case I' ve got my own settings object under in the confg.py module and it looks like this:
settings = Dynaconf(
envvar_prefix='MY_PREFIX',
settings_files=['settings.toml', '.secrets.toml'],
environments=True,
env_switcher='ENVIRONMENT_NAME',
)
and when I'm trying to do
from config import settings
@pytest.fixture(scope="session", autouse=True)
def set_test_settings():
settings.configure(FORCE_ENV_FOR_DYNACONF="testing")
it does not work. It only overrides settings imported directly from dynaconf module. This is a problem because in my app I'm using settings from my config.py and my tests are failing when I override settings from dynaconf and use from dynaconf import settings in tests - because in app I'm using from config import settings
Hi. I need to override the environment for settings in conftest.py. As I found I can do it by adding:
but in my case I' ve got my own settings object under in the
confg.pymodule and it looks like this:and when I'm trying to do
it does not work. It only overrides settings imported directly from dynaconf module. This is a problem because in my app I'm using settings from my
config.pyand my tests are failing when I override settings fromdynaconfand usefrom dynaconf import settingsin tests - because in app I'm usingfrom config import settings