Remove hacky workarounds to get encode/decode tests to pass on Windows

This commit is contained in:
Erik Johnson 2018-04-04 13:18:04 -05:00
parent 76e5d81bb4
commit f59cee28db
No known key found for this signature in database
GPG key ID: 5E5583C437808F3F
3 changed files with 8 additions and 13 deletions

View file

@ -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:

View file

@ -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,

View file

@ -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\\,' \