mirror of https://github.com/docker/docker-py.git
Fix py3.2 test failure and unicode behavior
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
311ae711d4
commit
a610a1be0e
|
@ -674,7 +674,7 @@ def parse_env_file(env_file):
|
||||||
|
|
||||||
|
|
||||||
def split_command(command):
|
def split_command(command):
|
||||||
if six.PY2:
|
if six.PY2 and not isinstance(command, six.binary_type):
|
||||||
command = command.encode('utf-8')
|
command = command.encode('utf-8')
|
||||||
return shlex.split(command)
|
return shlex.split(command)
|
||||||
|
|
||||||
|
|
|
@ -392,14 +392,18 @@ class UtilsTest(base.BaseTestCase):
|
||||||
|
|
||||||
class SplitCommandTest(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):
|
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):
|
def test_split_command_with_bytes(self):
|
||||||
expected = ['echo', u'μ'.encode('utf-8')]
|
self.assertEqual(split_command('echo μμ'), ['echo', 'μμ'])
|
||||||
self.assertEqual(split_command(u'echo μ'), expected)
|
|
||||||
|
|
||||||
|
|
||||||
class PortsTest(base.BaseTestCase):
|
class PortsTest(base.BaseTestCase):
|
||||||
|
|
Loading…
Reference in New Issue