mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add unit test for latin-1 fallback, multi-encoding
This commit is contained in:
parent
906644a80f
commit
f14f4dae22
1 changed files with 9 additions and 0 deletions
|
@ -18,6 +18,9 @@ STR = BYTES = UNICODE.encode('utf-8')
|
|||
# code points. Do not modify it.
|
||||
EGGS = '\u044f\u0438\u0306\u0446\u0430'
|
||||
|
||||
LATIN1_UNICODE = 'räksmörgås'
|
||||
LATIN1_BYTES = LATIN1_UNICODE.encode('latin-1')
|
||||
|
||||
|
||||
class StringutilsTestCase(TestCase):
|
||||
def test_contains_whitespace(self):
|
||||
|
@ -134,6 +137,8 @@ class StringutilsTestCase(TestCase):
|
|||
'яйца'
|
||||
)
|
||||
|
||||
self.assertEqual(salt.utils.stringutils.to_unicode(LATIN1_BYTES), LATIN1_UNICODE)
|
||||
|
||||
if six.PY3:
|
||||
self.assertEqual(salt.utils.stringutils.to_unicode('plugh'), 'plugh')
|
||||
self.assertEqual(salt.utils.stringutils.to_unicode('áéíóúý'), 'áéíóúý')
|
||||
|
@ -150,6 +155,10 @@ class StringutilsTestCase(TestCase):
|
|||
with patch.object(builtins, '__salt_system_encoding__', 'CP1252'):
|
||||
self.assertEqual(salt.utils.stringutils.to_unicode('Ψ'.encode('utf-8')), 'Ψ')
|
||||
|
||||
def test_to_unicode_multi_encoding(self):
|
||||
result = salt.utils.stringutils.to_unicode(LATIN1_BYTES, encoding=('utf-8', 'latin1'))
|
||||
assert result == LATIN1_UNICODE
|
||||
|
||||
def test_build_whitespace_split_regex(self):
|
||||
expected_regex = '(?m)^(?:[\\s]+)?Lorem(?:[\\s]+)?ipsum(?:[\\s]+)?dolor(?:[\\s]+)?sit(?:[\\s]+)?amet\\,' \
|
||||
'(?:[\\s]+)?$'
|
||||
|
|
Loading…
Add table
Reference in a new issue