mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Only run the ascii
case on Py2
This commit is contained in:
parent
3d1c4ce126
commit
c093d97a93
@ -28,8 +28,11 @@ class TestLocales(TestCase):
|
|||||||
reload_module(locales)
|
reload_module(locales)
|
||||||
|
|
||||||
def test_sdecode(self):
|
def test_sdecode(self):
|
||||||
b = '\xe7\xb9\x81\xe4\xbd\x93' if six.PY2 else bytes((0xe7, 0xb9, 0x81, 0xe4, 0xbd, 0x93))
|
b = six.b('\xe7\xb9\x81\xe4\xbd\x93')
|
||||||
u = u'\u7e41\u4f53'
|
u = u'\u7e41\u4f53'
|
||||||
|
if six.PY2:
|
||||||
|
# Under Py3, the above `b` as bytes, will never decode as anything even comparable using `ascii`
|
||||||
|
# but no unicode error will be raised, as such, sdecode will return the poorly decoded string
|
||||||
with patch('salt.utils.locales.get_encodings', return_value=['ascii']):
|
with patch('salt.utils.locales.get_encodings', return_value=['ascii']):
|
||||||
self.assertEqual(locales.sdecode(b), b) # no decode
|
self.assertEqual(locales.sdecode(b), b) # no decode
|
||||||
with patch('salt.utils.locales.get_encodings', return_value=['utf-8']):
|
with patch('salt.utils.locales.get_encodings', return_value=['utf-8']):
|
||||||
|
Loading…
Reference in New Issue
Block a user