summaryrefslogtreecommitdiffstats
path: root/ipatests
diff options
context:
space:
mode:
authorChristian Heimes <cheimes@redhat.com>2016-11-23 11:01:56 +0100
committerMartin Basti <mbasti@redhat.com>2016-11-25 16:18:22 +0100
commit7fef9cbec725beed62eb425449083c59416ed975 (patch)
tree1914842caa626e97396faaf641ec1282f6da2ba7 /ipatests
parent38e8719f728e6d54289507fe2c7f79f9272c45c0 (diff)
downloadfreeipa-7fef9cbec725beed62eb425449083c59416ed975.tar.gz
freeipa-7fef9cbec725beed62eb425449083c59416ed975.tar.xz
freeipa-7fef9cbec725beed62eb425449083c59416ed975.zip
Fix Python 3 bugs discovered by pylint
In Python 3 exception instances no longer have a message attribute. For most exceptions, str(e) or string formatting give the same result. Fix some renamed modules, module members and functions. https://fedorahosted.org/freeipa/ticket/4985 Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Martin Basti <mbasti@redhat.com>
Diffstat (limited to 'ipatests')
-rwxr-xr-xipatests/i18n.py12
-rw-r--r--ipatests/test_integration/env_config.py4
-rw-r--r--ipatests/test_integration/tasks.py3
-rw-r--r--ipatests/test_integration/test_idviews.py2
-rw-r--r--ipatests/test_xmlrpc/test_automount_plugin.py2
5 files changed, 16 insertions, 7 deletions
diff --git a/ipatests/i18n.py b/ipatests/i18n.py
index aa8932dd6..80f9827f5 100755
--- a/ipatests/i18n.py
+++ b/ipatests/i18n.py
@@ -32,6 +32,8 @@ import traceback
import polib
from collections import namedtuple
+import six
+
'''
We test our translations by taking the original untranslated string
(e.g. msgid) and prepend a prefix character and then append a suffix
@@ -610,8 +612,14 @@ def test_translations(po_file, lang, domain, locale_dir):
t = gettext.translation(domain, locale_dir)
- get_msgstr = t.ugettext
- get_msgstr_plural = t.ungettext
+ if six.PY2:
+ # pylint: disable=no-member
+ get_msgstr = t.ugettext
+ get_msgstr_plural = t.ungettext
+ # pylint: enable=no-member
+ else:
+ get_msgstr = t.gettext
+ get_msgstr_plural = t.ngettext
return po_file_iterate(po_file, get_msgstr, get_msgstr_plural)
diff --git a/ipatests/test_integration/env_config.py b/ipatests/test_integration/env_config.py
index 6e3770fbb..2a137c699 100644
--- a/ipatests/test_integration/env_config.py
+++ b/ipatests/test_integration/env_config.py
@@ -114,8 +114,8 @@ def config_from_env(env):
try:
import yaml
except ImportError as e:
- raise ImportError("%s, please install PyYAML package to fix it" %
- e.message)
+ raise ImportError(
+ "%s, please install PyYAML package to fix it" % e)
with open(env['IPATEST_YAML_CONFIG']) as file:
confdict = yaml.safe_load(file)
return Config.from_dict(confdict)
diff --git a/ipatests/test_integration/tasks.py b/ipatests/test_integration/tasks.py
index c6aab32f0..58b3a6510 100644
--- a/ipatests/test_integration/tasks.py
+++ b/ipatests/test_integration/tasks.py
@@ -1032,7 +1032,8 @@ def install_topo(topo, master, replicas, clients, domain_level=None,
def install_clients(servers, clients):
"""Install IPA clients, distributing them among the given servers"""
- for server, client in itertools.izip(itertools.cycle(servers), clients):
+ izip = getattr(itertools, 'izip', zip)
+ for server, client in izip(itertools.cycle(servers), clients):
log.info('Installing client %s on %s' % (server, client))
install_client(server, client)
diff --git a/ipatests/test_integration/test_idviews.py b/ipatests/test_integration/test_idviews.py
index 9df8c0a46..8a117e0b1 100644
--- a/ipatests/test_integration/test_idviews.py
+++ b/ipatests/test_integration/test_idviews.py
@@ -68,7 +68,7 @@ class TestCertsInIDOverrides(IntegrationTest):
# Initialize NSS database
tasks.run_certutil(master, ["-N", "-f", cls.pwname], cls.reqdir)
# Now generate self-signed certs for a windows user
- stdin_text = string.digits+string.letters[2:] + '\n'
+ stdin_text = string.digits+string.ascii_letters[2:] + '\n'
tasks.run_certutil(master, ['-S', '-s',
"cn=%s,dc=ad,dc=test" % cls.adcert1, '-n',
cls.adcert1, '-x', '-t', 'CT,C,C', '-v',
diff --git a/ipatests/test_xmlrpc/test_automount_plugin.py b/ipatests/test_xmlrpc/test_automount_plugin.py
index e3ad8b49d..aa39b6066 100644
--- a/ipatests/test_xmlrpc/test_automount_plugin.py
+++ b/ipatests/test_xmlrpc/test_automount_plugin.py
@@ -106,7 +106,7 @@ class AutomountTest(XMLRPC_test):
skipped=(),
duplicatemaps=(),
duplicatekeys=(),
- )), res)
+ )), res) # pylint: disable=used-before-assignment
self.check_tofiles()
finally:
res = api.Command['automountlocation_del'](self.locname)['result']