Kaydet (Commit) a610a1be authored tarafından Joffrey F's avatar Joffrey F

Fix py3.2 test failure and unicode behavior

Signed-off-by: 's avatarJoffrey F <joffrey@docker.com>
üst 311ae711
......@@ -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)
......
......@@ -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):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment