mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Py3 compatibility fixes
This commit is contained in:
parent
282aeb1d35
commit
a8bc298260
1 changed files with 8 additions and 5 deletions
|
@ -5,8 +5,8 @@
|
|||
'''
|
||||
# Import pytohn libs
|
||||
from __future__ import absolute_import
|
||||
import copy
|
||||
import os
|
||||
import copy
|
||||
import shutil
|
||||
import tempfile
|
||||
|
||||
|
@ -19,6 +19,9 @@ ensure_in_syspath('../../')
|
|||
import salt.utils
|
||||
from salt.utils import files as util_files
|
||||
|
||||
# Import 3rd-party libs
|
||||
import salt.ext.six as six
|
||||
|
||||
|
||||
class FilesTestCase(TestCase):
|
||||
|
||||
|
@ -32,18 +35,18 @@ class FilesTestCase(TestCase):
|
|||
}
|
||||
|
||||
def _create_temp_structure(self, temp_directory, structure):
|
||||
for folder, files in structure.items():
|
||||
for folder, files in six.iteritems(structure):
|
||||
current_directory = os.path.join(temp_directory, folder)
|
||||
os.makedirs(current_directory)
|
||||
for name, content in files.items():
|
||||
for name, content in six.iteritems(files):
|
||||
path = os.path.join(temp_directory, folder, name)
|
||||
with salt.utils.fopen(path, 'w+') as fh:
|
||||
fh.write(content)
|
||||
|
||||
def _validate_folder_structure_and_contents(self, target_directory,
|
||||
desired_structure):
|
||||
for folder, files in desired_structure.items():
|
||||
for name, content in files.items():
|
||||
for folder, files in six.iteritems(desired_structure):
|
||||
for name, content in six.iteritems(files):
|
||||
path = os.path.join(target_directory, folder, name)
|
||||
with salt.utils.fopen(path) as fh:
|
||||
assert fh.read().strip() == content
|
||||
|
|
Loading…
Add table
Reference in a new issue