From 16ca5b9694756b49657b68d9551e3a0255076658 Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Tue, 21 Aug 2018 21:53:12 -0700 Subject: [PATCH] Work around listdir encoding issues on py2 windows --- tests/integration/states/test_file.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/integration/states/test_file.py b/tests/integration/states/test_file.py index 5ede7a632a35..82058fb7359a 100644 --- a/tests/integration/states/test_file.py +++ b/tests/integration/states/test_file.py @@ -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): '''