python-configuration
python-configuration copied to clipboard
Patching ConfigurationSet
What is the proper way to patch a config using something like @patch.dict? In the example below, I would like to insert a custom url value in the test.
Sample config:
configs.py
from config import ConfigurationSet, config_from_env, config_from_yaml
CONFIG = ConfigurationSet(
config_from_yaml(f'{BASE_PATH}/{FLAVOR}.yaml', read_from_file=True),
config_from_yaml(f'{BASE_PATH}/default.yaml', read_from_file=True),
)
client.py
import requests
from configs import CONFIG
def send_get():
response = request.get(CONFIG['url'])
For a ConfigurationSet, you can patch the _configs dictionary and add another Configuration object with the url setting you need.