Example #1
0
def test_user_can_use_number_types_with_dotenv(env_path):
    config = Tailor()
    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
Example #2
0
def test_from_obj_and_then_dotenv(env_path):
    config = Tailor()
    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
Example #3
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 pytailor import Tailor

from .config import DevConfig

# create your config object to be used in your application
config = Tailor()

# 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")
Example #4
0
def test_from_dotenv(env_path):
    config = Tailor()
    config.from_dotenv(env_path)
    assert "DEBUG" in config
    assert config["DEBUG"] is True