Fix file and copy modules on py3 and enable tests. (#17239)

- Fix octal formatting of file mode in module response on py3.
- Convert file path to unicode in copy action.
- Enable file and copy module tests for py3 now that they pass.
pull/17244/head
Matt Clay 8 years ago committed by GitHub
parent 44d979c8f5
commit 178292d2cd

@ -1197,7 +1197,7 @@ class AnsibleModule(object):
kwargs['owner'] = user kwargs['owner'] = user
kwargs['group'] = group kwargs['group'] = group
st = os.lstat(path) st = os.lstat(path)
kwargs['mode'] = oct(stat.S_IMODE(st[stat.ST_MODE])) kwargs['mode'] = '0%03o' % stat.S_IMODE(st[stat.ST_MODE])
# secontext not yet supported # secontext not yet supported
if os.path.islink(path): if os.path.islink(path):
kwargs['state'] = 'link' kwargs['state'] = 'link'

@ -113,7 +113,7 @@ class ActionModule(ActionBase):
# Walk the directory and append the file tuples to source_files. # Walk the directory and append the file tuples to source_files.
for base_path, sub_folders, files in os.walk(to_bytes(source)): for base_path, sub_folders, files in os.walk(to_bytes(source)):
for file in files: for file in files:
full_path = os.path.join(base_path, file) full_path = to_unicode(os.path.join(base_path, file), errors='strict')
rel_path = full_path[sz:] rel_path = full_path[sz:]
if rel_path.startswith('/'): if rel_path.startswith('/'):
rel_path = rel_path[1:] rel_path = rel_path[1:]

@ -3,8 +3,6 @@ test_apt
test_assemble test_assemble
test_async test_async
test_authorized_key test_authorized_key
test_copy
test_file
test_filters test_filters
test_gem test_gem
test_get_url test_get_url

Loading…
Cancel
Save