fopen does not support encoding

This commit is contained in:
Daniel A. Wozniak 2018-06-28 10:16:52 -07:00
parent 487161ba8f
commit e8362adf71
No known key found for this signature in database
GPG key ID: 166B9D2C06C82D61

View file

@ -93,9 +93,9 @@ class GitModuleTest(ModuleCase):
dir_path = os.path.join(self.repo, dirname)
_makedirs(dir_path)
for filename in self.files:
with salt.utils.files.fopen(os.path.join(dir_path, filename), 'w', encoding='utf-8') as fp_:
with salt.utils.files.fopen(os.path.join(dir_path, filename), 'wb') as fp_:
fp_.write(
'This is a test file named {0}.'.format(filename)
'This is a test file named {0}.'.format(filename).encode('utf-8')
)
# Navigate to the root of the repo to init, stage, and commit
os.chdir(self.repo)
@ -166,9 +166,9 @@ class GitModuleTest(ModuleCase):
files = [os.path.join(newdir_path, x) for x in self.files]
files_relpath = [os.path.join(newdir, x) for x in self.files]
for path in files:
with salt.utils.files.fopen(path, 'w', encoding='utf-8') as fp_:
with salt.utils.files.fopen(path, 'wb') as fp_:
fp_.write(
'This is a test file with relative path {0}.\n'.format(path)
'This is a test file with relative path {0}.\n'.format(path).encode('utf-8')
)
ret = self.run_function('git.add', [self.repo, newdir])
res = '\n'.join(sorted(['add \'{0}\''.format(x) for x in files_relpath]))