|
@@ -1,3 +1,4 @@
|
|
|
+# -*- coding: utf-8 -*-
|
|
|
from __future__ import absolute_import
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
@@ -12,6 +13,7 @@ from collections import namedtuple
|
|
|
from operator import attrgetter
|
|
|
|
|
|
import py
|
|
|
+import six
|
|
|
import yaml
|
|
|
from docker import errors
|
|
|
|
|
@@ -1286,6 +1288,23 @@ class CLITestCase(DockerClientTestCase):
|
|
|
'simplecomposefile_simple_run_1',
|
|
|
'exited'))
|
|
|
|
|
|
+ @mock.patch.dict(os.environ)
|
|
|
+ def test_run_unicode_env_values_from_system(self):
|
|
|
+ value = 'ą, ć, ę, ł, ń, ó, ś, ź, ż'
|
|
|
+ if six.PY2: # os.environ doesn't support unicode values in Py2
|
|
|
+ os.environ['BAR'] = value.encode('utf-8')
|
|
|
+ else: # ... and doesn't support byte values in Py3
|
|
|
+ os.environ['BAR'] = value
|
|
|
+ self.base_dir = 'tests/fixtures/unicode-environment'
|
|
|
+ result = self.dispatch(['run', 'simple'])
|
|
|
+
|
|
|
+ if six.PY2: # Can't retrieve output on Py3. See issue #3670
|
|
|
+ assert value == result.stdout.strip()
|
|
|
+
|
|
|
+ container = self.project.containers(one_off=OneOffFilter.only, stopped=True)[0]
|
|
|
+ environment = container.get('Config.Env')
|
|
|
+ assert 'FOO={}'.format(value) in environment
|
|
|
+
|
|
|
@mock.patch.dict(os.environ)
|
|
|
def test_run_env_values_from_system(self):
|
|
|
os.environ['FOO'] = 'bar'
|