-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Don't break when volume binds contain unicode characters #787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
tests/utils_test.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be able to avoid this step if we go:
expected = [six.u('/mnt/지연:/unicode/박:rw')]
c822470
to
332d1ea
Compare
@aanand Thanks, didn't know about |
Cool. Perhaps the first test should be rewritten so it tests byte string input on all Python versions: def test_convert_volume_bindings_binary_input(self):
expected = [six.u('/mnt/지연:/unicode/박:rw')]
data = {
b'/mnt/지연': {
'bind': b'/unicode/박',
'mode': 'rw'
}
}
self.assertEqual(
convert_volume_binds(data), expected
) |
332d1ea
to
b2e9144
Compare
Okay, I've tried all sorts of combination, I've settled on just separating py2 and py3 tests completely (so it's 2+2 now). On the bright side, results were consistent all along (and we have tests to prove it)! |
OK, I see the rationale, but instead of entirely separate test methods, could we just switch on the Python version inside the method? def test_convert_volume_binds_unicode_bytes_input(self):
if six.PY2:
expected = [unicode('/mnt/지연:/unicode/박:rw', 'utf-8')]
data = {
'/mnt/지연': {
'bind': '/unicode/박',
'mode': 'rw'
}
}
else:
expected = ['/mnt/지연:/unicode/박:rw']
data = {
bytes('/mnt/지연', 'utf-8'): {
'bind': bytes('/unicode/박', 'utf-8'),
'mode': 'rw'
}
}
self.assertEqual(convert_volume_binds(data), expected)
def test_convert_volume_binds_unicode_unicode_input(self):
if six.PY2:
expected = [unicode('/mnt/지연:/unicode/박:rw', 'utf-8')]
data = {
unicode('/mnt/지연', 'utf-8'): {
'bind': unicode('/unicode/박', 'utf-8'),
'mode': 'rw'
}
}
else:
expected = ['/mnt/지연:/unicode/박:rw']
data = {
'/mnt/지연': {
'bind': '/unicode/박',
'mode': 'rw'
}
}
self.assertEqual(convert_volume_binds(data), expected) |
Also includes a few unit tests for utils.convert_volume_binds Signed-off-by: Joffrey F <joffrey@docker.com>
b2e9144
to
29219a2
Compare
Don't break when volume binds contain unicode characters
Also includes a few unit tests for utils.convert_volume_binds
Fixes #782