diff --git a/salt/client/__init__.py b/salt/client/__init__.py index 69b06a66fc..1780b300f5 100644 --- a/salt/client/__init__.py +++ b/salt/client/__init__.py @@ -19,7 +19,7 @@ The data structure needs to be: # 4. How long do we wait for all of the replies? # # Import python libs -from __future__ import absolute_import, print_function +from __future__ import absolute_import, print_function, unicode_literals import os import time import random @@ -38,6 +38,7 @@ import salt.utils.files import salt.utils.jid import salt.utils.minions import salt.utils.platform +import salt.utils.stringutils import salt.utils.user import salt.utils.verify import salt.utils.versions @@ -196,7 +197,7 @@ class LocalClient(object): key_user, self.skip_perm_errors) with salt.utils.files.fopen(keyfile, 'r') as key: - return key.read() + return salt.utils.stringutils.to_unicode(key.read()) except (OSError, IOError, SaltClientError): # Fall back to eauth return '' @@ -1795,7 +1796,7 @@ class LocalClient(object): **kwargs) master_uri = 'tcp://' + salt.utils.zeromq.ip_bracket(self.opts['interface']) + \ - ':' + str(self.opts['ret_port']) + ':' + six.text_type(self.opts['ret_port']) channel = salt.transport.Channel.factory(self.opts, crypt='clear', master_uri=master_uri) @@ -1903,7 +1904,7 @@ class LocalClient(object): **kwargs) master_uri = 'tcp://' + salt.utils.zeromq.ip_bracket(self.opts['interface']) + \ - ':' + str(self.opts['ret_port']) + ':' + six.text_type(self.opts['ret_port']) channel = salt.transport.client.AsyncReqChannel.factory(self.opts, io_loop=io_loop, crypt='clear', diff --git a/salt/client/api.py b/salt/client/api.py index affdbe06db..083651fb89 100644 --- a/salt/client/api.py +++ b/salt/client/api.py @@ -16,7 +16,7 @@ client applications. ''' # Import Python libs -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import os # Import Salt libs diff --git a/salt/client/mixins.py b/salt/client/mixins.py index 01ddcc3b72..29b6077661 100644 --- a/salt/client/mixins.py +++ b/salt/client/mixins.py @@ -4,7 +4,7 @@ A collection of mixins useful for the various *Client interfaces ''' # Import Python libs -from __future__ import absolute_import, print_function, with_statement +from __future__ import absolute_import, print_function, with_statement, unicode_literals import fnmatch import signal import logging @@ -395,7 +395,7 @@ class SyncClientMixin(object): data['success'] = salt.utils.state.check_result(data['return']['data']) except (Exception, SystemExit) as ex: if isinstance(ex, salt.exceptions.NotImplemented): - data['return'] = str(ex) + data['return'] = six.text_type(ex) else: data['return'] = 'Exception occurred in {0} {1}: {2}'.format( self.client, diff --git a/salt/client/netapi.py b/salt/client/netapi.py index 95d4adf139..e85725d56c 100644 --- a/salt/client/netapi.py +++ b/salt/client/netapi.py @@ -3,7 +3,7 @@ The main entry point for salt-api ''' # Import python libs -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import signal import logging diff --git a/salt/client/raet/__init__.py b/salt/client/raet/__init__.py index 21af331acb..376ae1e499 100644 --- a/salt/client/raet/__init__.py +++ b/salt/client/raet/__init__.py @@ -2,7 +2,7 @@ ''' The client libs to communicate with the salt master when running raet ''' -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals # Import python libs import os diff --git a/salt/client/ssh/__init__.py b/salt/client/ssh/__init__.py index 1f173c6ec6..3c580f84fe 100644 --- a/salt/client/ssh/__init__.py +++ b/salt/client/ssh/__init__.py @@ -3,7 +3,7 @@ Create ssh executor system ''' # Import python libs -from __future__ import absolute_import, print_function +from __future__ import absolute_import, print_function, unicode_literals import base64 import copy import getpass diff --git a/salt/client/ssh/client.py b/salt/client/ssh/client.py index 085ac406b0..99428d211f 100644 --- a/salt/client/ssh/client.py +++ b/salt/client/ssh/client.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Import Python libs -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import os import copy import logging diff --git a/salt/client/ssh/shell.py b/salt/client/ssh/shell.py index 2d246701d3..1bcb19f278 100644 --- a/salt/client/ssh/shell.py +++ b/salt/client/ssh/shell.py @@ -2,7 +2,7 @@ ''' Manage transport commands via ssh ''' -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals # Import python libs import re @@ -18,6 +18,8 @@ import salt.defaults.exitcodes import salt.utils.nb_popen import salt.utils.vt +from salt.ext import six + log = logging.getLogger(__name__) SSH_PASSWORD_PROMPT_RE = re.compile(r'(?:.*)[Pp]assword(?: for .*)?:', re.M) @@ -88,7 +90,7 @@ class Shell(object): self.host = host.strip('[]') self.user = user self.port = port - self.passwd = str(passwd) if passwd else passwd + self.passwd = six.text_type(passwd) if passwd else passwd self.priv = priv self.timeout = timeout self.sudo = sudo diff --git a/salt/client/ssh/ssh_py_shim.py b/salt/client/ssh/ssh_py_shim.py index 6c1957d1df..b4f11f87d7 100644 --- a/salt/client/ssh/ssh_py_shim.py +++ b/salt/client/ssh/ssh_py_shim.py @@ -8,7 +8,7 @@ helper script used by salt.client.ssh.Single. It is here, in a separate file, for convenience of development. ''' -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import hashlib import tarfile diff --git a/salt/client/ssh/state.py b/salt/client/ssh/state.py index 223992bb06..bc04f893eb 100644 --- a/salt/client/ssh/state.py +++ b/salt/client/ssh/state.py @@ -2,7 +2,7 @@ ''' Create ssh executor system ''' -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals # Import python libs import logging import os @@ -17,6 +17,7 @@ import salt.client.ssh.shell import salt.client.ssh import salt.utils.files import salt.utils.path +import salt.utils.stringutils import salt.utils.thin import salt.utils.url import salt.utils.verify @@ -180,13 +181,13 @@ def prep_trans_tar(opts, file_client, chunks, file_refs, pillar=None, id_=None, [salt.utils.url.create('_utils')], ] with salt.utils.files.fopen(lowfn, 'w+') as fp_: - fp_.write(json.dumps(chunks)) + fp_.write(salt.utils.stringutils.to_str(json.dumps(chunks))) if pillar: with salt.utils.files.fopen(pillarfn, 'w+') as fp_: - fp_.write(json.dumps(pillar)) + fp_.write(salt.utils.stringutils.to_str(json.dumps(pillar))) if roster_grains: with salt.utils.files.fopen(roster_grainsfn, 'w+') as fp_: - fp_.write(json.dumps(roster_grains)) + fp_.write(salt.utils.stringutils.to_str(json.dumps(roster_grains))) if id_ is None: id_ = '' @@ -194,7 +195,7 @@ def prep_trans_tar(opts, file_client, chunks, file_refs, pillar=None, id_=None, cachedir = os.path.join('salt-ssh', id_).rstrip(os.sep) except AttributeError: # Minion ID should always be a str, but don't let an int break this - cachedir = os.path.join('salt-ssh', str(id_)).rstrip(os.sep) + cachedir = os.path.join('salt-ssh', six.string_types(id_)).rstrip(os.sep) for saltenv in file_refs: # Location where files in this saltenv will be cached diff --git a/salt/client/ssh/wrapper/__init__.py b/salt/client/ssh/wrapper/__init__.py index 5ae13486b1..7727cab30c 100644 --- a/salt/client/ssh/wrapper/__init__.py +++ b/salt/client/ssh/wrapper/__init__.py @@ -7,7 +7,7 @@ as ZeroMQ salt, but via ssh. ''' # Import python libs -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import json import copy diff --git a/salt/client/ssh/wrapper/config.py b/salt/client/ssh/wrapper/config.py index 94edbfbea8..61f79092bb 100644 --- a/salt/client/ssh/wrapper/config.py +++ b/salt/client/ssh/wrapper/config.py @@ -4,7 +4,7 @@ Return config information ''' # Import python libs -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import re import os diff --git a/salt/client/ssh/wrapper/cp.py b/salt/client/ssh/wrapper/cp.py index 4be91c0da4..08d7388522 100644 --- a/salt/client/ssh/wrapper/cp.py +++ b/salt/client/ssh/wrapper/cp.py @@ -3,13 +3,14 @@ Wrap the cp module allowing for managed ssh file transfers ''' # Import Python libs -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import logging import os # Import salt libs import salt.client.ssh import salt.utils.files +import salt.utils.stringutils import salt.utils.templates from salt.exceptions import CommandExecutionError @@ -141,7 +142,7 @@ def _render_filenames(path, dest, saltenv, template): # write out path to temp file tmp_path_fn = salt.utils.files.mkstemp() with salt.utils.files.fopen(tmp_path_fn, 'w+') as fp_: - fp_.write(contents) + fp_.write(salt.utils.stringutils.to_str(contents)) data = salt.utils.templates.TEMPLATE_REGISTRY[template]( tmp_path_fn, to_str=True, diff --git a/salt/client/ssh/wrapper/grains.py b/salt/client/ssh/wrapper/grains.py index 47f3446912..0791a419b1 100644 --- a/salt/client/ssh/wrapper/grains.py +++ b/salt/client/ssh/wrapper/grains.py @@ -4,7 +4,7 @@ Return/control aspects of the grains data ''' # Import python libs -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import collections import copy import math diff --git a/salt/client/ssh/wrapper/mine.py b/salt/client/ssh/wrapper/mine.py index 32d7a2e3fd..d2a3a9dcdb 100644 --- a/salt/client/ssh/wrapper/mine.py +++ b/salt/client/ssh/wrapper/mine.py @@ -7,7 +7,7 @@ Wrapper function for mine operations for salt-ssh ''' # Import python libs -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import copy # Import salt libs diff --git a/salt/client/ssh/wrapper/pillar.py b/salt/client/ssh/wrapper/pillar.py index 69ffe5dcc2..4ee66efba6 100644 --- a/salt/client/ssh/wrapper/pillar.py +++ b/salt/client/ssh/wrapper/pillar.py @@ -2,7 +2,7 @@ ''' Extract the pillar data for this minion ''' -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals # Import python libs import collections diff --git a/salt/client/ssh/wrapper/publish.py b/salt/client/ssh/wrapper/publish.py index 4866cb4d44..4e5ff668c8 100644 --- a/salt/client/ssh/wrapper/publish.py +++ b/salt/client/ssh/wrapper/publish.py @@ -10,7 +10,7 @@ salt-ssh calls and return the data from them. No access control is needed because calls cannot originate from the minions. ''' # Import python libs -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import copy import logging diff --git a/salt/client/ssh/wrapper/state.py b/salt/client/ssh/wrapper/state.py index b3ffe5fc3a..2651ef8748 100644 --- a/salt/client/ssh/wrapper/state.py +++ b/salt/client/ssh/wrapper/state.py @@ -3,7 +3,7 @@ Create ssh executor system ''' -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals # Import python libs import os import time @@ -177,7 +177,7 @@ def sls(mods, saltenv='base', test=None, exclude=None, **kwargs): return json.loads(stdout, object_hook=salt.utils.data.decode_dict) except Exception as e: log.error("JSON Render failed for: %s\n%s", stdout, stderr) - log.error(str(e)) + log.error(six.text_type(e)) # If for some reason the json load fails, return the stdout return stdout @@ -347,7 +347,7 @@ def low(data, **kwargs): return json.loads(stdout, object_hook=salt.utils.data.decode_dict) except Exception as e: log.error("JSON Render failed for: %s\n%s", stdout, stderr) - log.error(str(e)) + log.error(six.text_type(e)) # If for some reason the json load fails, return the stdout return stdout @@ -435,7 +435,7 @@ def high(data, **kwargs): return json.loads(stdout, object_hook=salt.utils.data.decode_dict) except Exception as e: log.error("JSON Render failed for: %s\n%s", stdout, stderr) - log.error(str(e)) + log.error(six.text_type(e)) # If for some reason the json load fails, return the stdout return stdout @@ -521,6 +521,8 @@ def check_request(name=None): serial = salt.payload.Serial(__opts__) if os.path.isfile(notify_path): with salt.utils.files.fopen(notify_path, 'rb') as fp_: + # Not sure if this needs to be decoded since it is being returned, + # and msgpack serialization will encode it to bytes anyway. req = serial.load(fp_) if name: return req[name] @@ -676,7 +678,7 @@ def highstate(test=None, **kwargs): return json.loads(stdout, object_hook=salt.utils.data.decode_dict) except Exception as e: log.error("JSON Render failed for: %s\n%s", stdout, stderr) - log.error(str(e)) + log.error(six.text_type(e)) # If for some reason the json load fails, return the stdout return stdout @@ -756,7 +758,7 @@ def top(topfn, test=None, **kwargs): return json.loads(stdout, object_hook=salt.utils.data.decode_dict) except Exception as e: log.error("JSON Render failed for: %s\n%s", stdout, stderr) - log.error(str(e)) + log.error(six.text_type(e)) # If for some reason the json load fails, return the stdout return stdout @@ -1119,7 +1121,7 @@ def single(fun, name, test=None, **kwargs): return json.loads(stdout, object_hook=salt.utils.data.decode_dict) except Exception as e: log.error("JSON Render failed for: %s\n%s", stdout, stderr) - log.error(str(e)) + log.error(six.text_type(e)) # If for some reason the json load fails, return the stdout return stdout diff --git a/salt/key.py b/salt/key.py index ca485362fd..23387d5b18 100644 --- a/salt/key.py +++ b/salt/key.py @@ -5,7 +5,7 @@ used to manage salt keys directly without interfacing with the CLI. ''' # Import python libs -from __future__ import absolute_import, print_function +from __future__ import absolute_import, print_function, unicode_literals import os import copy import json @@ -30,6 +30,7 @@ import salt.utils.files import salt.utils.kinds import salt.utils.master import salt.utils.sdb +import salt.utils.stringutils import salt.utils.user # pylint: disable=import-error,no-name-in-module,redefined-builtin @@ -125,7 +126,8 @@ class KeyCLI(object): if 'token' in self.opts: try: with salt.utils.files.fopen(os.path.join(self.opts['key_dir'], '.root_key'), 'r') as fp_: - low['key'] = fp_.readline() + low['key'] = \ + salt.utils.stringutils.to_unicode(fp_.readline()) except IOError: low['token'] = self.opts['token'] # @@ -606,7 +608,9 @@ class Key(object): for fn_ in salt.utils.data.sorted_ignorecase(os.listdir(dir_)): if not fn_.startswith('.'): if os.path.isfile(os.path.join(dir_, fn_)): - ret[os.path.basename(dir_)].append(fn_) + ret[os.path.basename(dir_)].append( + salt.utils.stringutils.to_unicode(fn_) + ) except (OSError, IOError): # key dir kind is not created yet, just skip continue @@ -664,7 +668,8 @@ class Key(object): for key in salt.utils.data.sorted_ignorecase(keys): path = os.path.join(self.opts['pki_dir'], status, key) with salt.utils.files.fopen(path, 'r') as fp_: - ret[status][key] = fp_.read() + ret[status][key] = \ + salt.utils.stringutils.to_unicode(fp_.read()) return ret def key_str_all(self): @@ -677,7 +682,8 @@ class Key(object): for key in salt.utils.data.sorted_ignorecase(keys): path = os.path.join(self.opts['pki_dir'], status, key) with salt.utils.files.fopen(path, 'r') as fp_: - ret[status][key] = fp_.read() + ret[status][key] = \ + salt.utils.stringutils.to_unicode(fp_.read()) return ret def accept(self, match=None, match_dict=None, include_rejected=False, include_denied=False): @@ -1026,11 +1032,14 @@ class RaetKey(Key): continue path = os.path.join(road_cache, road) with salt.utils.files.fopen(path, 'rb') as fp_: + # Do not use to_unicode to decode this. It needs to stay as + # bytes to be deserialized. if ext == '.json': data = json.load(fp_) elif ext == '.msgpack': data = msgpack.load(fp_) - if data['role'] not in minions: + role = salt.utils.stringutils.to_unicode(data['role']) + if role not in minions: os.remove(path) def gen_keys(self, keydir=None, keyname=None, keysize=None, user=None): diff --git a/salt/runner.py b/salt/runner.py index f1f833d735..e7bd4cd2c3 100644 --- a/salt/runner.py +++ b/salt/runner.py @@ -4,7 +4,7 @@ Execute salt convenience routines ''' # Import python libs -from __future__ import absolute_import, print_function +from __future__ import absolute_import, print_function, unicode_literals import os import logging @@ -206,7 +206,7 @@ class Runner(RunnerClient): if 'token' in self.opts: try: with salt.utils.files.fopen(os.path.join(self.opts['key_dir'], '.root_key'), 'r') as fp_: - low['key'] = fp_.readline() + low['key'] = salt.utils.stringutils.to_unicode(fp_.readline()) except IOError: low['token'] = self.opts['token'] diff --git a/salt/wheel/__init__.py b/salt/wheel/__init__.py index ad0d4c1478..9ddcb384fa 100644 --- a/salt/wheel/__init__.py +++ b/salt/wheel/__init__.py @@ -4,7 +4,7 @@ Modules used to control the master itself ''' # Import Python libs -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import collections # Import salt libs @@ -15,6 +15,9 @@ import salt.transport import salt.utils.error import salt.utils.zeromq +# Import 3rd-party libs +from salt.ext import six + class WheelClient(salt.client.mixins.SyncClientMixin, salt.client.mixins.AsyncClientMixin, object): @@ -65,7 +68,7 @@ class WheelClient(salt.client.mixins.SyncClientMixin, if interface == '0.0.0.0': interface = '127.0.0.1' master_uri = 'tcp://' + salt.utils.zeromq.ip_bracket(interface) + \ - ':' + str(self.opts['ret_port']) + ':' + six.text_type(self.opts['ret_port']) channel = salt.transport.Channel.factory(self.opts, crypt='clear', master_uri=master_uri, diff --git a/salt/wheel/config.py b/salt/wheel/config.py index 146604c774..470a39c3f0 100644 --- a/salt/wheel/config.py +++ b/salt/wheel/config.py @@ -2,7 +2,7 @@ ''' Manage the master configuration file ''' -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals # Import python libs import logging @@ -16,6 +16,9 @@ import salt.config import salt.utils.files from salt.utils.yamldumper import SafeOrderedDumper +# Import 3rd-party libs +from salt.ext import six + log = logging.getLogger(__name__) @@ -84,7 +87,7 @@ def update_config(file_name, yaml_contents): yaml_out = yaml.safe_dump(yaml_contents, default_flow_style=False) if not os.path.exists(dir_path): - log.debug('Creating directory {0}'.format(dir_path)) + log.debug('Creating directory %s', dir_path) os.makedirs(dir_path, 0o755) file_path = os.path.join(dir_path, file_name) @@ -93,4 +96,4 @@ def update_config(file_name, yaml_contents): return 'Wrote {0}'.format(file_name) except (IOError, OSError, yaml.YAMLError, ValueError) as err: - return str(err) + return six.text_type(err) diff --git a/salt/wheel/error.py b/salt/wheel/error.py index 79ba16421f..10bede9feb 100644 --- a/salt/wheel/error.py +++ b/salt/wheel/error.py @@ -3,7 +3,7 @@ Error generator to enable integration testing of salt wheel error handling ''' -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals # Import python libs diff --git a/salt/wheel/file_roots.py b/salt/wheel/file_roots.py index 54c0aabdf8..5d98d32bd5 100644 --- a/salt/wheel/file_roots.py +++ b/salt/wheel/file_roots.py @@ -4,7 +4,7 @@ Read in files from the file_root and save files to the file root ''' # Import python libs -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import os # Import salt libs @@ -88,7 +88,9 @@ def read(path, saltenv='base'): form = fn_[full] if form == 'txt': with salt.utils.files.fopen(full, 'rb') as fp_: - ret.append({full: fp_.read()}) + ret.append( + {full: salt.utils.stringutils.to_unicode(fp_.read())} + ) return ret @@ -110,5 +112,5 @@ def write(data, path, saltenv='base', index=0): if not os.path.isdir(dest_dir): os.makedirs(dest_dir) with salt.utils.files.fopen(dest, 'w+') as fp_: - fp_.write(data) + fp_.write(salt.utils.stringutils.to_str(data)) return 'Wrote data to file {0}'.format(dest) diff --git a/salt/wheel/key.py b/salt/wheel/key.py index a4dcf7a787..26601b90f5 100644 --- a/salt/wheel/key.py +++ b/salt/wheel/key.py @@ -28,7 +28,7 @@ using the :ref:`saltutil execution module `. ''' # Import python libs -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import os import hashlib import logging @@ -356,9 +356,9 @@ def gen(id_=None, keysize=2048): priv = salt.crypt.gen_keys(__opts__['pki_dir'], id_, keysize) pub = '{0}.pub'.format(priv[:priv.rindex('.')]) with salt.utils.files.fopen(priv) as fp_: - ret['priv'] = fp_.read() + ret['priv'] = salt.utils.stringutils.to_unicode(fp_.read()) with salt.utils.files.fopen(pub) as fp_: - ret['pub'] = fp_.read() + ret['pub'] = salt.utils.stringutils.to_unicode(fp_.read()) # The priv key is given the Read-Only attribute. The causes `os.remove` to # fail in Windows. @@ -416,7 +416,7 @@ def gen_accept(id_, keysize=2048, force=False): if os.path.isfile(acc_path) and not force: return {} with salt.utils.files.fopen(acc_path, 'w+') as fp_: - fp_.write(ret['pub']) + fp_.write(salt.utils.stringutils.to_str(ret['pub'])) return ret diff --git a/salt/wheel/minions.py b/salt/wheel/minions.py index 95d45356ad..75bddce863 100644 --- a/salt/wheel/minions.py +++ b/salt/wheel/minions.py @@ -4,7 +4,7 @@ Wheel system wrapper for connected minions ''' # Import Python libs -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals # Import Salt libs from salt.utils.cache import CacheCli diff --git a/salt/wheel/pillar_roots.py b/salt/wheel/pillar_roots.py index 61438c7857..36a673cc95 100644 --- a/salt/wheel/pillar_roots.py +++ b/salt/wheel/pillar_roots.py @@ -5,7 +5,7 @@ directories on the master server. ''' # Import python libs -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import os # Import salt libs @@ -89,7 +89,9 @@ def read(path, saltenv='base'): form = fn_[full] if form == 'txt': with salt.utils.files.fopen(full, 'rb') as fp_: - ret.append({full: fp_.read()}) + ret.append( + {full: salt.utils.stringutils.to_unicode(fp_.read())} + ) return ret @@ -111,5 +113,5 @@ def write(data, path, saltenv='base', index=0): if not os.path.isdir(dest_dir): os.makedirs(dest_dir) with salt.utils.files.fopen(dest, 'w+') as fp_: - fp_.write(data) + fp_.write(salt.utils.stringutils.to_str(data)) return 'Wrote data to file {0}'.format(dest) diff --git a/tests/integration/client/test_kwarg.py b/tests/integration/client/test_kwarg.py index ac4d69a0e7..c6d39102a2 100644 --- a/tests/integration/client/test_kwarg.py +++ b/tests/integration/client/test_kwarg.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Import python libs -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals # Import Salt Testing libs from tests.support.case import ModuleCase diff --git a/tests/integration/client/test_runner.py b/tests/integration/client/test_runner.py index 989bcb69a8..c11b3da1a9 100644 --- a/tests/integration/client/test_runner.py +++ b/tests/integration/client/test_runner.py @@ -1,7 +1,7 @@ # coding: utf-8 # Import python libs -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals # Import Salt Testing libs from tests.support.unit import TestCase diff --git a/tests/integration/client/test_standard.py b/tests/integration/client/test_standard.py index b0e8809da1..963f55911f 100644 --- a/tests/integration/client/test_standard.py +++ b/tests/integration/client/test_standard.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Import python libs -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import os # Import Salt Testing libs diff --git a/tests/integration/client/test_syndic.py b/tests/integration/client/test_syndic.py index cb26df64de..c6b268e69c 100644 --- a/tests/integration/client/test_syndic.py +++ b/tests/integration/client/test_syndic.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Import Python libs -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals # Import Salt Testing libs from tests.support.case import SyndicCase diff --git a/tests/integration/files/file/base/_wheel/runtests_helpers.py b/tests/integration/files/file/base/_wheel/runtests_helpers.py index 136d2c0a28..5adc98c9de 100644 --- a/tests/integration/files/file/base/_wheel/runtests_helpers.py +++ b/tests/integration/files/file/base/_wheel/runtests_helpers.py @@ -4,7 +4,7 @@ Wheel functions for integration tests ''' # Import python libs -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals def failure(): diff --git a/tests/integration/netapi/test_client.py b/tests/integration/netapi/test_client.py index 6270b0dcc2..7f860ba2ca 100644 --- a/tests/integration/netapi/test_client.py +++ b/tests/integration/netapi/test_client.py @@ -1,7 +1,7 @@ # encoding: utf-8 # Import Python libs -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import os # Import Salt Testing libs diff --git a/tests/integration/shell/test_key.py b/tests/integration/shell/test_key.py index 6ae22b3d39..9326294eb0 100644 --- a/tests/integration/shell/test_key.py +++ b/tests/integration/shell/test_key.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Import Python libs -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import os import shutil import tempfile @@ -14,6 +14,7 @@ from tests.support.mixins import ShellCaseCommonTestsMixin # Import 3rd-party libs import yaml +from salt.ext import six # Import Salt libs import salt.utils.files @@ -42,7 +43,7 @@ class KeyTest(ShellCase, ShellCaseCommonTestsMixin): self.assertTrue(add_user) self.assertTrue(add_pwd) user_list = self.run_call('user.list_users') - self.assertIn(USERA, str(user_list)) + self.assertIn(USERA, six.text_type(user_list)) except AssertionError: self.run_call('user.delete {0} remove=True'.format(USERA)) self.skipTest( diff --git a/tests/integration/ssh/test_deploy.py b/tests/integration/ssh/test_deploy.py index 1daab7ffab..8dfdc8d3ff 100644 --- a/tests/integration/ssh/test_deploy.py +++ b/tests/integration/ssh/test_deploy.py @@ -3,7 +3,7 @@ salt-ssh testing ''' # Import Python libs -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import os import shutil diff --git a/tests/integration/ssh/test_grains.py b/tests/integration/ssh/test_grains.py index 5da68325ac..83a4c6a448 100644 --- a/tests/integration/ssh/test_grains.py +++ b/tests/integration/ssh/test_grains.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Import Python libs -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals # Import Salt Testing Libs from tests.support.case import SSHCase diff --git a/tests/integration/ssh/test_mine.py b/tests/integration/ssh/test_mine.py index c8f3a311e4..273be3350d 100644 --- a/tests/integration/ssh/test_mine.py +++ b/tests/integration/ssh/test_mine.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Import Python libs -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import os import shutil diff --git a/tests/integration/ssh/test_pillar.py b/tests/integration/ssh/test_pillar.py index 579e663180..929612d1ca 100644 --- a/tests/integration/ssh/test_pillar.py +++ b/tests/integration/ssh/test_pillar.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Import Python libs -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals # Import Salt Testing Libs from tests.support.case import SSHCase diff --git a/tests/integration/ssh/test_raw.py b/tests/integration/ssh/test_raw.py index 9d64a5cd28..5feeb23ebc 100644 --- a/tests/integration/ssh/test_raw.py +++ b/tests/integration/ssh/test_raw.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Import Python libs -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals # Import Salt Testing Libs from tests.support.case import SSHCase diff --git a/tests/integration/ssh/test_state.py b/tests/integration/ssh/test_state.py index cf4a035ea9..a5c44b5fc0 100644 --- a/tests/integration/ssh/test_state.py +++ b/tests/integration/ssh/test_state.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Import Python libs -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import os import shutil diff --git a/tests/integration/wheel/test_client.py b/tests/integration/wheel/test_client.py index 7b6fe3f58e..bc17f09daa 100644 --- a/tests/integration/wheel/test_client.py +++ b/tests/integration/wheel/test_client.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Import Python libs -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals # Import Salt Testing libs from tests.support.unit import TestCase, skipIf diff --git a/tests/integration/wheel/test_key.py b/tests/integration/wheel/test_key.py index 3923a76ba5..6bfe2529f8 100644 --- a/tests/integration/wheel/test_key.py +++ b/tests/integration/wheel/test_key.py @@ -1,7 +1,7 @@ # coding: utf-8 # Import python libs -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals # Import Salt Testing libs from tests.support.unit import TestCase diff --git a/tests/unit/modules/test_key.py b/tests/unit/modules/test_key.py index 5c540fffef..5fa86eaec9 100644 --- a/tests/unit/modules/test_key.py +++ b/tests/unit/modules/test_key.py @@ -4,7 +4,7 @@ ''' # Import Python libs -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import os.path # Import Salt Testing Libs diff --git a/tests/unit/test_client.py b/tests/unit/test_client.py index 44bd75dd50..af9bc8f05e 100644 --- a/tests/unit/test_client.py +++ b/tests/unit/test_client.py @@ -4,7 +4,7 @@ ''' # Import python libs -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals # Import Salt Testing libs import tests.integration as integration