Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple unittest fixes for 2018.3 Python 3 Windows #49577

Merged
merged 1 commit into from Sep 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions tests/unit/utils/test_files.py
Expand Up @@ -47,14 +47,14 @@ def test_safe_walk_symlink_recursion(self, tmp):
if os.stat(tmp).st_ino == 0:
self.skipTest('inodes not supported in {0}'.format(tmp))
os.mkdir(os.path.join(tmp, 'fax'))
os.makedirs(os.path.join(tmp, 'foo/bar'))
os.symlink('../..', os.path.join(tmp, 'foo/bar/baz'))
os.makedirs(os.path.join(tmp, 'foo', 'bar'))
os.symlink(os.path.join('..', '..'), os.path.join(tmp, 'foo', 'bar', 'baz'))
os.symlink('foo', os.path.join(tmp, 'root'))
expected = [
(os.path.join(tmp, 'root'), ['bar'], []),
(os.path.join(tmp, 'root/bar'), ['baz'], []),
(os.path.join(tmp, 'root/bar/baz'), ['fax', 'foo', 'root'], []),
(os.path.join(tmp, 'root/bar/baz/fax'), [], []),
(os.path.join(tmp, 'root', 'bar'), ['baz'], []),
(os.path.join(tmp, 'root', 'bar', 'baz'), ['fax', 'foo', 'root'], []),
(os.path.join(tmp, 'root', 'bar', 'baz', 'fax'), [], []),
]
paths = []
for root, dirs, names in salt.utils.files.safe_walk(os.path.join(tmp, 'root')):
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/utils/test_jinja.py
Expand Up @@ -368,7 +368,7 @@ def test_non_ascii_encoding(self):
self.assertEqual(fc.requests[0]['path'], 'salt://macro')

filename = os.path.join(self.template_dir, 'non_ascii')
with salt.utils.files.fopen(filename) as fp_:
with salt.utils.files.fopen(filename, 'rb') as fp_:
out = render_jinja_tmpl(
salt.utils.stringutils.to_unicode(fp_.read(), 'utf-8'),
dict(opts={'cachedir': self.tempdir, 'file_client': 'remote',
Expand Down Expand Up @@ -435,7 +435,7 @@ def test_non_ascii(self):
saltenv='test',
salt=self.local_salt
)
with salt.utils.files.fopen(out['data']) as fp:
with salt.utils.files.fopen(out['data'], 'rb') as fp:
result = salt.utils.stringutils.to_unicode(fp.read(), 'utf-8')
self.assertEqual(salt.utils.stringutils.to_unicode('Assunção' + os.linesep), result)

Expand Down
8 changes: 4 additions & 4 deletions tests/unit/utils/test_json.py
Expand Up @@ -137,9 +137,9 @@ def test_dump_load(self, json_out):
'''
Test dumping to and loading from a file handle
'''
with salt.utils.files.fopen(json_out, 'w') as fp_:
salt.utils.json.dump(self.data, fp_)
with salt.utils.files.fopen(json_out, 'r') as fp_:
ret = salt.utils.json.load(fp_)
with salt.utils.files.fopen(json_out, 'wb') as fp_:
fp_.write(salt.utils.to_bytes(salt.utils.json.dumps(self.data)))
with salt.utils.files.fopen(json_out, 'rb') as fp_:
ret = salt.utils.json.loads(salt.utils.to_unicode(fp_.read()))
# Loading should be equal to the original data
self.assertEqual(ret, self.data)