Merge pull request #45536 from twangboy/win_fix_test_configparser

Fix `unit.utils.test_configparser` for Windows
This commit is contained in:
Nicole Thomas 2018-01-19 15:14:58 -05:00 committed by GitHub
commit 061c7e3bcb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -74,7 +74,11 @@ class GitConfigParser(RawConfigParser, object): # pylint: disable=undefined-var
while True: while True:
line = fp.readline() line = fp.readline()
if six.PY2: if six.PY2:
line = line.decode(__salt_system_encoding__) try:
line = line.decode(__salt_system_encoding__)
except UnicodeDecodeError:
# Fall back to UTF-8
line = line.decode('utf-8')
if not line: if not line:
break break
lineno = lineno + 1 lineno = lineno + 1

View File

@ -71,7 +71,7 @@ class TestGitConfigParser(TestCase):
with salt.utils.files.fopen(self.orig_config, 'wb') as fp_: with salt.utils.files.fopen(self.orig_config, 'wb') as fp_:
fp_.write( fp_.write(
salt.utils.stringutils.to_bytes( salt.utils.stringutils.to_bytes(
'\n'.join(ORIG_CONFIG) os.linesep.join(ORIG_CONFIG)
) )
) )
self.conf = salt.utils.configparser.GitConfigParser() self.conf = salt.utils.configparser.GitConfigParser()