def test_env_var_is_set_then_gets_removed_with_default_value_set(): config = Config() config.from_object(DevConfig) config.from_envar("FOO") assert config["FOO"] == "BAR" del os.environ["FOO"] assert config["FOO"] == "BAZ"
def test_from_obj_and_then_dotenv(self, env_path): config = Config() config.from_dotenv(env_path) config.from_object(DevConfig) assert "DEBUG" in config assert "TESTING" in config assert config["DEBUG"] is True assert config["TESTING"] is False
def test_from_object(self): config = Config() config.from_object(DevConfig) assert "DEBUG" in config assert config["DEBUG"] is True
# -*- coding: utf-8 -*- # alternatively, you can load config values from a .env file path # note: you can choose which file is more important, .env or from object # by choosing which order to load the files in from pathlib import Path from configureme import Config from .config import DevConfig # create your config object to be used in your application config = Config() # load your configuration from a default object config.from_object(DevConfig) path = Path("examples/basic") / ".env" config.from_dotenv(str(path)) # you can also watch environment variables # note: environment variables will always take precedence # over any other value config.from_envar("TESTING")