Skip to content

Commit

Permalink
Merge b1ee56b into a04f22b
Browse files Browse the repository at this point in the history
  • Loading branch information
Sytten committed Jul 4, 2017
2 parents a04f22b + b1ee56b commit c8d2fea
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions Pipfile
Expand Up @@ -18,3 +18,4 @@ future = "*"
m2r = "*"
PyYAML = "*"
Flask = "*"
python-box = "*"
4 changes: 4 additions & 0 deletions dynaconf/base.py
Expand Up @@ -3,6 +3,7 @@
import importlib
import logging
from contextlib import contextmanager
from box import Box

import os
import sys
Expand Down Expand Up @@ -421,6 +422,9 @@ def unset_all(self, keys): # pragma: no cover
def set(self, key, value, loader_identifier=None):
"""Set a value storing references for the loader"""
value = parse_conf_data(value)
if isinstance(value, dict):
value = Box(value, box_it_up=True)

key = key.strip().upper()
setattr(self, key, value)
self.store[key] = value
Expand Down
1 change: 1 addition & 0 deletions requirements_dev.txt
Expand Up @@ -6,6 +6,7 @@ PyYAML
toml
flask>=0.12
m2r
python-box

# testing
coveralls
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -31,7 +31,7 @@ def parse_md_to_rst(file):

setup(
name='dynaconf',
version="0.4.5",
version="0.5.0",
url='https://github.com/rochacbruno/dynaconf',
license='MIT',
author="Bruno Rocha",
Expand Down
11 changes: 11 additions & 0 deletions tests/test_yaml_loader.py
Expand Up @@ -11,6 +11,12 @@
example:
host: server.com
port: 8080
service:
url: service.com
port: 80
auth:
password: qwerty
test: 1234
development:
host: dev_server.com
"""
Expand All @@ -21,6 +27,11 @@ def test_load_from_yaml():
load(settings, filename=YAML)
assert settings.HOST == 'server.com'
assert settings.PORT == 8080
assert settings.SERVICE['url'] == 'service.com'
assert settings.SERVICE.url == 'service.com'
assert settings.SERVICE.port == 80
assert settings.SERVICE.auth.password == 'qwerty'
assert settings.SERVICE.auth.test == 1234
load(settings, filename=YAML, namespace='DEVELOPMENT')
assert settings.HOST == 'dev_server.com'
load(settings, filename=YAML)
Expand Down

0 comments on commit c8d2fea

Please sign in to comment.