Skip to content

Commit

Permalink
Work around listdir encoding issues on py2 windows
Browse files Browse the repository at this point in the history
  • Loading branch information
dwoz authored and rallytime committed Aug 28, 2018
1 parent 7650208 commit 16ca5b9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tests/integration/states/test_file.py
Expand Up @@ -1272,14 +1272,18 @@ def test_recurse_issue_40578(self, name):
name=name,
source='salt://соль')
self.assertSaltTrueReturn(ret)
# Providing unicode to os.listdir so that we avoid having listdir try
# to decode the filenames using the systemencoding on windows.
if six.PY2 and salt.utils.platform.is_windows():
# Providing unicode to os.listdir so that we avoid having listdir
# try to decode the filenames using the systemencoding on windows
# python 2.
files = os.listdir(name.decode('utf-8'))
else:
files = salt.utils.data.decode(os.listdir(name), normalize=True)
self.assertEqual(
sorted(os.listdir(name.decode('utf-8'))),
sorted(files),
sorted(['foo.txt', 'спам.txt', 'яйца.txt']),
)


@with_tempfile()
def test_replace(self, name):
'''
Expand Down

0 comments on commit 16ca5b9

Please sign in to comment.