diff options
author | Joffrey F <joffrey@docker.com> | 2016-10-12 17:19:08 -0700 |
---|---|---|
committer | Joffrey F <joffrey@docker.com> | 2016-10-12 17:52:43 -0700 |
commit | 059f61bf5a7b3252c1980342befe47ec6ea8f6bd (patch) | |
tree | 1e84a4389bf1b2d9428fca521de898fdb5e30570 /tests/unit/utils_test.py | |
parent | 008730c670afb2f88c7db308901586fb24f1a60c (diff) | |
download | docker-py-format_env_unicode_bug.tar.gz |
Do not break when calling format_environment with unicode valuesformat_env_unicode_bug
Signed-off-by: Joffrey F <joffrey@docker.com>
Diffstat (limited to 'tests/unit/utils_test.py')
-rw-r--r-- | tests/unit/utils_test.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/tests/unit/utils_test.py b/tests/unit/utils_test.py index 2a2759d..8fc7ab4 100644 --- a/tests/unit/utils_test.py +++ b/tests/unit/utils_test.py @@ -20,11 +20,11 @@ from docker.utils import ( create_host_config, Ulimit, LogConfig, parse_bytes, parse_env_file, exclude_paths, convert_volume_binds, decode_json_header, tar, split_command, create_ipam_config, create_ipam_pool, parse_devices, - update_headers, + update_headers ) from docker.utils.ports import build_port_bindings, split_port -from docker.utils.utils import create_endpoint_config +from docker.utils.utils import create_endpoint_config, format_environment from .. import base from ..helpers import make_tree @@ -1042,3 +1042,18 @@ class TarTest(base.Cleanup, base.BaseTestCase): self.assertEqual( sorted(tar_data.getnames()), ['bar', 'bar/foo', 'foo'] ) + + +class FormatEnvironmentTest(base.BaseTestCase): + def test_format_env_binary_unicode_value(self): + env_dict = { + 'ARTIST_NAME': b'\xec\x86\xa1\xec\xa7\x80\xec\x9d\x80' + } + assert format_environment(env_dict) == [u'ARTIST_NAME=송지은'] + + def test_format_env_no_value(self): + env_dict = { + 'FOO': None, + 'BAR': '', + } + assert sorted(format_environment(env_dict)) == ['BAR=', 'FOO'] |