Exemplo n.º 1
0
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"
Exemplo n.º 2
0
 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
Exemplo n.º 3
0
 def test_from_object(self):
     config = Config()
     config.from_object(DevConfig)
     assert "DEBUG" in config
     assert config["DEBUG"] is True
Exemplo n.º 4
0
# -*- 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")