summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2015-10-27 18:01:19 +0100
committerJoffrey F <joffrey@docker.com>2015-10-27 18:01:19 +0100
commita610a1be0eaefdfa10b0dc91b0f1e49fc1e93cb2 (patch)
tree14ed44029314365db7e9c437f3978ff1e1e38afd
parent311ae711d49ed28ecef42c806fac7afb8f53ea85 (diff)
downloaddocker-py-a610a1be0eaefdfa10b0dc91b0f1e49fc1e93cb2.tar.gz
Fix py3.2 test failure and unicode behavior
Signed-off-by: Joffrey F <joffrey@docker.com>
-rw-r--r--docker/utils/utils.py2
-rw-r--r--tests/unit/utils_test.py14
2 files changed, 10 insertions, 6 deletions
diff --git a/docker/utils/utils.py b/docker/utils/utils.py
index 4d2968a..39d0eba 100644
--- a/docker/utils/utils.py
+++ b/docker/utils/utils.py
@@ -674,7 +674,7 @@ def parse_env_file(env_file):
def split_command(command):
- if six.PY2:
+ if six.PY2 and not isinstance(command, six.binary_type):
command = command.encode('utf-8')
return shlex.split(command)
diff --git a/tests/unit/utils_test.py b/tests/unit/utils_test.py
index c20fa5f..93f95a1 100644
--- a/tests/unit/utils_test.py
+++ b/tests/unit/utils_test.py
@@ -392,14 +392,18 @@ class UtilsTest(base.BaseTestCase):
class SplitCommandTest(base.BaseTestCase):
- @pytest.mark.skipif(six.PY2, reason="shlex doesn't support unicode in py2")
def test_split_command_with_unicode(self):
- self.assertEqual(split_command('echo μ'), ['echo', 'μ'])
+ if six.PY2:
+ self.assertEqual(
+ split_command(unicode('echo μμ', 'utf-8')),
+ ['echo', 'μμ']
+ )
+ else:
+ self.assertEqual(split_command('echo μμ'), ['echo', 'μμ'])
- @pytest.mark.skipif(six.PY3, reason="shlex doesn't support unicode in py2")
+ @pytest.mark.skipif(six.PY3, reason="shlex doesn't support bytes in py3")
def test_split_command_with_bytes(self):
- expected = ['echo', u'μ'.encode('utf-8')]
- self.assertEqual(split_command(u'echo μ'), expected)
+ self.assertEqual(split_command('echo μμ'), ['echo', 'μμ'])
class PortsTest(base.BaseTestCase):