Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions compose/config/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,11 @@
def split_env(env):
if isinstance(env, six.binary_type):
env = env.decode('utf-8', 'replace')
key = value = None

if '=' in env:
key, value = env.split('=', 1)
else:
key = env
if re.search(r'\s', key):
raise ConfigurationError(
"environment variable name '{}' may not contain whitespace.".format(key)
)
return key, value

return env, None

def env_vars_from_file(filename):
"""
Expand Down
9 changes: 0 additions & 9 deletions tests/unit/config/environment_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,3 @@ def test_env_vars_from_file_bom(self):
assert env_vars_from_file(str(tmpdir.join('bom.env'))) == {
'PARK_BOM': '박봄'
}

def test_env_vars_from_file_whitespace(self):
tmpdir = pytest.ensuretemp('env_file')
self.addCleanup(tmpdir.remove)
with codecs.open('{}/whitespace.env'.format(str(tmpdir)), 'w', encoding='utf-8') as f:
f.write('WHITESPACE =yes\n')
with pytest.raises(ConfigurationError) as exc:
env_vars_from_file(str(tmpdir.join('whitespace.env')))
assert 'environment variable' in exc.exconly()