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
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_dotenv(self, env_path): config = Config() config.from_dotenv(env_path) 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")