示例#1
0
 def test_user_can_use_number_types_with_dotenv(self, env_path):
     config = Config()
     config.from_dotenv(env_path)
     assert isinstance(config["MAX_LINES"], int)
     assert config["MAX_LINES"] == 10
     assert isinstance(config["TEMPERATURE"], float)
     assert config["TEMPERATURE"] == 98.2
示例#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
示例#3
0
 def test_from_dotenv(self, env_path):
     config = Config()
     config.from_dotenv(env_path)
     assert "DEBUG" in config
     assert config["DEBUG"] is True
示例#4
0
文件: app.py 项目: f1x3d/configureme
# -*- 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")