diff options
author | Daniel Nephin <dnephin@gmail.com> | 2016-02-24 15:55:58 -0800 |
---|---|---|
committer | Daniel Nephin <dnephin@gmail.com> | 2016-02-24 15:55:58 -0800 |
commit | 44555f323f312d793449af243913ff7ef46b1351 (patch) | |
tree | 44f881a70a8e5f1fd6abc2adbeebe97cbf450a7c | |
parent | 507503cdfa1a922624d92d522cbf18f6683b87ec (diff) | |
parent | 3bad04649d0b25209e0c1dd0c1772fe2cc854c3c (diff) | |
download | docker-py-44555f323f312d793449af243913ff7ef46b1351.tar.gz |
Merge pull request #958 from dnephin/oops_fix_empty_env_vars_again
Fix env vars with empty values
-rw-r--r-- | docker/utils/utils.py | 2 | ||||
-rw-r--r-- | tests/integration/container_test.py | 7 |
2 files changed, 6 insertions, 3 deletions
diff --git a/docker/utils/utils.py b/docker/utils/utils.py index bde18b6..8182a43 100644 --- a/docker/utils/utils.py +++ b/docker/utils/utils.py @@ -823,7 +823,7 @@ def split_command(command): def format_environment(environment): def format_env(key, value): - if not value: + if value is None: return key return '{key}={value}'.format(key=key, value=value) return [format_env(*var) for var in six.iteritems(environment)] diff --git a/tests/integration/container_test.py b/tests/integration/container_test.py index eb5b746..91f0604 100644 --- a/tests/integration/container_test.py +++ b/tests/integration/container_test.py @@ -374,11 +374,14 @@ class CreateContainerTest(helpers.BaseTestCase): container = self.client.create_container( BUSYBOX, ['echo'], - environment={'Foo': None, 'Other': 'one'}, + environment={'Foo': None, 'Other': 'one', 'Blank': ''}, ) self.tmp_containers.append(container['Id']) config = self.client.inspect_container(container['Id']) - assert sorted(config['Config']['Env']) == sorted(['Foo', 'Other=one']) + assert ( + sorted(config['Config']['Env']) == + sorted(['Foo', 'Other=one', 'Blank=']) + ) class VolumeBindTest(helpers.BaseTestCase): |