Skip to content

Commit

Permalink
Fix check in configuration with env=None (#3562)
Browse files Browse the repository at this point in the history
  • Loading branch information
sjperkins authored and mrocklin committed Jun 7, 2018
1 parent 3535483 commit 08f1d03
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dask/config.py
Expand Up @@ -271,7 +271,7 @@ def collect(paths=paths, env=None):
--------
dask.config.refresh: collect configuration and update into primary config
"""
if os is None:
if env is None:
env = os.environ
configs = []

Expand Down
38 changes: 35 additions & 3 deletions dask/tests/test_config.py
Expand Up @@ -3,9 +3,9 @@

import pytest

from dask.config import (update, merge, collect_yaml, collect_env, get,
ensure_file, set, config, rename, update_defaults,
refresh)
from dask.config import (update, merge, collect, collect_yaml, collect_env,
get, ensure_file, set, config, rename,
update_defaults, refresh)
from dask.utils import tmpfile


Expand Down Expand Up @@ -100,6 +100,38 @@ def test_env():
assert collect_env(env) == expected


def test_collect():
a = {'x': 1, 'y': {'a': 1}}
b = {'x': 2, 'z': 3, 'y': {'b': 2}}
env = {'DASK_W': 4}

expected = {
'w': 4,
'x': 2,
'y': {'a': 1, 'b': 2},
'z': 3,
}

with tmpfile(extension='yaml') as fn1:
with tmpfile(extension='yaml') as fn2:
with open(fn1, 'w') as f:
yaml.dump(a, f)
with open(fn2, 'w') as f:
yaml.dump(b, f)

config = collect([fn1, fn2], env=env)
assert config == expected


def test_collect_env_none():
os.environ['DASK_FOO'] = 'bar'
try:
config = collect([])
assert config == {'foo': 'bar'}
finally:
del os.environ['DASK_FOO']


def test_get():
d = {'x': 1, 'y': {'a': 2}}

Expand Down

0 comments on commit 08f1d03

Please sign in to comment.