mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Remove hacky workarounds to get encode/decode tests to pass on Windows
This commit is contained in:
parent
76e5d81bb4
commit
f59cee28db
3 changed files with 8 additions and 13 deletions
|
@ -147,8 +147,7 @@ class GitModuleTest(ModuleCase):
|
|||
TODO: maybe move this behavior to ModuleCase itself?
|
||||
'''
|
||||
return salt.utils.data.decode(
|
||||
super(GitModuleTest, self).run_function(*args, **kwargs),
|
||||
encoding='utf-8'
|
||||
super(GitModuleTest, self).run_function(*args, **kwargs)
|
||||
)
|
||||
|
||||
def tearDown(self):
|
||||
|
@ -207,8 +206,7 @@ class GitModuleTest(ModuleCase):
|
|||
self.run_function('cmd.run', ['cp ' + tar_archive + ' /root/'])
|
||||
with closing(tarfile.open(tar_archive, 'r')) as tar_obj:
|
||||
self.assertEqual(
|
||||
sorted(salt.utils.data.decode(tar_obj.getnames(),
|
||||
encoding='utf-8')),
|
||||
sorted(salt.utils.data.decode(tar_obj.getnames())),
|
||||
sorted([
|
||||
'foo', 'foo/bar', 'foo/baz', 'foo/foo', 'foo/питон',
|
||||
'foo/qux', 'foo/qux/bar', 'foo/qux/baz', 'foo/qux/foo',
|
||||
|
@ -238,8 +236,7 @@ class GitModuleTest(ModuleCase):
|
|||
self.assertTrue(tarfile.is_tarfile(tar_archive))
|
||||
with closing(tarfile.open(tar_archive, 'r')) as tar_obj:
|
||||
self.assertEqual(
|
||||
sorted(salt.utils.data.decode(tar_obj.getnames(),
|
||||
encoding='utf-8')),
|
||||
sorted(salt.utils.data.decode(tar_obj.getnames())),
|
||||
sorted(['foo', 'foo/bar', 'foo/baz', 'foo/foo', 'foo/питон'])
|
||||
)
|
||||
finally:
|
||||
|
|
|
@ -240,7 +240,6 @@ class DataTestCase(TestCase):
|
|||
|
||||
ret = salt.utils.data.decode(
|
||||
self.test_data,
|
||||
encoding='utf-8',
|
||||
keep=True,
|
||||
normalize=True,
|
||||
preserve_dict_class=True,
|
||||
|
@ -253,7 +252,6 @@ class DataTestCase(TestCase):
|
|||
UnicodeDecodeError,
|
||||
salt.utils.data.decode,
|
||||
self.test_data,
|
||||
encoding='utf-8',
|
||||
keep=False,
|
||||
normalize=True,
|
||||
preserve_dict_class=True,
|
||||
|
@ -267,7 +265,6 @@ class DataTestCase(TestCase):
|
|||
|
||||
ret = salt.utils.data.decode(
|
||||
self.test_data,
|
||||
encoding='utf-8',
|
||||
keep=True,
|
||||
normalize=True,
|
||||
preserve_dict_class=False,
|
||||
|
|
|
@ -97,7 +97,6 @@ class StringutilsTestCase(TestCase):
|
|||
self.assertEqual(
|
||||
salt.utils.stringutils.to_unicode(
|
||||
EGGS,
|
||||
encoding='utf=8',
|
||||
normalize=True
|
||||
),
|
||||
'яйца'
|
||||
|
@ -105,7 +104,6 @@ class StringutilsTestCase(TestCase):
|
|||
self.assertNotEqual(
|
||||
salt.utils.stringutils.to_unicode(
|
||||
EGGS,
|
||||
encoding='utf=8',
|
||||
normalize=False
|
||||
),
|
||||
'яйца'
|
||||
|
@ -120,9 +118,12 @@ class StringutilsTestCase(TestCase):
|
|||
self.assertEqual(salt.utils.stringutils.to_unicode(str('xyzzy'), 'utf-8'), 'xyzzy') # future lint: disable=blacklisted-function
|
||||
self.assertEqual(salt.utils.stringutils.to_unicode(BYTES, 'utf-8'), UNICODE)
|
||||
|
||||
# Test utf-8 fallback with ascii default encoding
|
||||
# Test that unicode chars are decoded properly even when using
|
||||
# locales which are not UTF-8 compatible
|
||||
with patch.object(builtins, '__salt_system_encoding__', 'ascii'):
|
||||
self.assertEqual(salt.utils.stringutils.to_unicode(u'Ψ'.encode('utf-8')), u'Ψ')
|
||||
self.assertEqual(salt.utils.stringutils.to_unicode('Ψ'.encode('utf-8')), 'Ψ')
|
||||
with patch.object(builtins, '__salt_system_encoding__', 'CP1252'):
|
||||
self.assertEqual(salt.utils.stringutils.to_unicode('Ψ'.encode('utf-8')), 'Ψ')
|
||||
|
||||
def test_build_whitespace_split_regex(self):
|
||||
expected_regex = '(?m)^(?:[\\s]+)?Lorem(?:[\\s]+)?ipsum(?:[\\s]+)?dolor(?:[\\s]+)?sit(?:[\\s]+)?amet\\,' \
|
||||
|
|
Loading…
Add table
Reference in a new issue