summaryrefslogtreecommitdiffstats
path: root/ipatests
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2015-07-30 16:49:29 +0200
committerTomas Babej <tbabej@redhat.com>2015-08-12 18:17:23 +0200
commit27dabb45282911e375336f75934af9dd6cc5d963 (patch)
tree3c8fe5255d60613fa9cd14d053b3688feed740c9 /ipatests
parenta651be3eec2a08bd2865b16b0eed767db69aab0f (diff)
downloadfreeipa-27dabb45282911e375336f75934af9dd6cc5d963.tar.gz
freeipa-27dabb45282911e375336f75934af9dd6cc5d963.tar.xz
freeipa-27dabb45282911e375336f75934af9dd6cc5d963.zip
Modernize 'except' clauses
The 'as' syntax works from Python 2 on, and Python 3 will drop the "comma" syntax. Reviewed-By: Tomas Babej <tbabej@redhat.com>
Diffstat (limited to 'ipatests')
-rwxr-xr-xipatests/i18n.py14
-rwxr-xr-xipatests/ipa-test-task2
-rw-r--r--ipatests/test_cmdline/cmdline.py2
-rw-r--r--ipatests/test_cmdline/test_ipagetkeytab.py6
-rw-r--r--ipatests/test_ipalib/test_rpc.py10
-rw-r--r--ipatests/test_ipapython/test_keyring.py2
-rw-r--r--ipatests/test_ipapython/test_ssh.py2
-rw-r--r--ipatests/test_ipaserver/test_changepw.py2
-rw-r--r--ipatests/test_pkcs10/test_pkcs10.py4
-rw-r--r--ipatests/test_webui/ui_driver.py12
-rw-r--r--ipatests/test_xmlrpc/test_sudorule_plugin.py2
-rw-r--r--ipatests/test_xmlrpc/xmlrpc_test.py4
-rw-r--r--ipatests/util.py2
13 files changed, 32 insertions, 32 deletions
diff --git a/ipatests/i18n.py b/ipatests/i18n.py
index 7d31e4d87..369871658 100755
--- a/ipatests/i18n.py
+++ b/ipatests/i18n.py
@@ -415,7 +415,7 @@ def validate_file(file_path, validation_mode, reference_pot=None):
try:
po = polib.pofile(file_path)
- except Exception, e:
+ except Exception as e:
error_lines.append(entry_seperator)
error_lines.append('Unable to parse file "%s": %s' % (file_path, e))
n_errors += 1
@@ -528,7 +528,7 @@ def create_po(pot_file, po_file, mo_file):
return 1
try:
po = polib.pofile(pot_file)
- except Exception, e:
+ except Exception as e:
print >>sys.stderr, 'Unable to parse file "%s": %s' % (pot_file, e)
return 1
@@ -619,7 +619,7 @@ def po_file_iterate(po_file, get_msgstr, get_msgstr_plural):
return 1
try:
po = polib.pofile(po_file)
- except Exception, e:
+ except Exception as e:
print >>sys.stderr, 'Unable to parse file "%s": %s' % (po_file, e)
return 1
@@ -638,7 +638,7 @@ def po_file_iterate(po_file, get_msgstr, get_msgstr_plural):
n_translations += 1
validate_unicode_edit(msgid, msgstr)
n_valid += 1
- except Exception, e:
+ except Exception as e:
n_fail += 1
if print_traceback:
traceback.print_exc()
@@ -648,7 +648,7 @@ def po_file_iterate(po_file, get_msgstr, get_msgstr_plural):
n_translations += 1
validate_unicode_edit(msgid_plural, msgstr_plural)
n_valid += 1
- except Exception, e:
+ except Exception as e:
n_fail += 1
if print_traceback:
traceback.print_exc()
@@ -663,7 +663,7 @@ def po_file_iterate(po_file, get_msgstr, get_msgstr_plural):
n_translations += 1
validate_unicode_edit(msgid, msgstr)
n_valid += 1
- except Exception, e:
+ except Exception as e:
n_fail += 1
if print_traceback:
traceback.print_exc()
@@ -671,7 +671,7 @@ def po_file_iterate(po_file, get_msgstr, get_msgstr_plural):
n_entries += 1
- except Exception, e:
+ except Exception as e:
if print_traceback:
traceback.print_exc()
print >> sys.stderr, "ERROR: %s" % e
diff --git a/ipatests/ipa-test-task b/ipatests/ipa-test-task
index 8c9ab082f..192814c48 100755
--- a/ipatests/ipa-test-task
+++ b/ipatests/ipa-test-task
@@ -287,7 +287,7 @@ class TaskRunner(object):
try:
return args.func(args)
- except Exception, e:
+ except Exception as e:
if args.with_beakerlib:
beakerlib_process.log_exception()
beakerlib_process.run_beakerlib_command(
diff --git a/ipatests/test_cmdline/cmdline.py b/ipatests/test_cmdline/cmdline.py
index a7ed67793..0ae8cc079 100644
--- a/ipatests/test_cmdline/cmdline.py
+++ b/ipatests/test_cmdline/cmdline.py
@@ -42,7 +42,7 @@ try:
server_available = True
except errors.DatabaseError:
server_available = False
-except Exception, e:
+except Exception as e:
server_available = False
class cmdline_test(XMLRPC_test):
diff --git a/ipatests/test_cmdline/test_ipagetkeytab.py b/ipatests/test_cmdline/test_ipagetkeytab.py
index bc948bf09..2b99c268e 100644
--- a/ipatests/test_cmdline/test_ipagetkeytab.py
+++ b/ipatests/test_cmdline/test_ipagetkeytab.py
@@ -48,7 +48,7 @@ def use_keytab(principal, keytab):
conn = ldap2(api)
conn.connect(ccache=ccache)
conn.disconnect()
- except krbV.Krb5Error, e:
+ except krbV.Krb5Error as e:
raise StandardError('Unable to bind to LDAP. Error initializing principal %s in %s: %s' % (principal.name, keytab, str(e)))
finally:
del os.environ['KRB5CCNAME']
@@ -111,7 +111,7 @@ class test_ipagetkeytab(cmdline_test):
expected = 'Keytab successfully retrieved and stored in: %s\n' % (
self.keytabname)
assert expected in err, 'Success message not in output:\n%s' % err
- except ipautil.CalledProcessError, e:
+ except ipautil.CalledProcessError as e:
assert (False)
def test_3_use(self):
@@ -141,7 +141,7 @@ class test_ipagetkeytab(cmdline_test):
"""
try:
use_keytab(self.service_princ, self.keytabname)
- except StandardError, errmsg:
+ except StandardError as errmsg:
assert('Unable to bind to LDAP. Error initializing principal' in str(errmsg))
def test_9_cleanup(self):
diff --git a/ipatests/test_ipalib/test_rpc.py b/ipatests/test_ipalib/test_rpc.py
index b61337474..dd24d055c 100644
--- a/ipatests/test_ipalib/test_rpc.py
+++ b/ipatests/test_ipalib/test_rpc.py
@@ -274,7 +274,7 @@ class test_xml_introspection(object):
def test_list_methods_many_params(self):
try:
result = api.Backend.xmlclient.conn.system.listMethods('foo')
- except Fault, f:
+ except Fault as f:
print f
assert f.faultCode == 3003
assert f.faultString == (
@@ -294,7 +294,7 @@ class test_xml_introspection(object):
def test_signature_no_params(self):
try:
result = api.Backend.xmlclient.conn.system.methodSignature()
- except Fault, f:
+ except Fault as f:
print f
assert f.faultCode == 3007
assert f.faultString == "'method name' is required"
@@ -304,7 +304,7 @@ class test_xml_introspection(object):
def test_signature_many_params(self):
try:
result = api.Backend.xmlclient.conn.system.methodSignature('a', 'b')
- except Fault, f:
+ except Fault as f:
print f
assert f.faultCode == 3004
assert f.faultString == (
@@ -315,7 +315,7 @@ class test_xml_introspection(object):
def test_help_no_params(self):
try:
result = api.Backend.xmlclient.conn.system.methodHelp()
- except Fault, f:
+ except Fault as f:
print f
assert f.faultCode == 3007
assert f.faultString == "'method name' is required"
@@ -325,7 +325,7 @@ class test_xml_introspection(object):
def test_help_many_params(self):
try:
result = api.Backend.xmlclient.conn.system.methodHelp('a', 'b')
- except Fault, f:
+ except Fault as f:
print f
assert f.faultCode == 3004
assert f.faultString == (
diff --git a/ipatests/test_ipapython/test_keyring.py b/ipatests/test_ipapython/test_keyring.py
index e92b1b465..bd876ea77 100644
--- a/ipatests/test_ipapython/test_keyring.py
+++ b/ipatests/test_ipapython/test_keyring.py
@@ -59,7 +59,7 @@ class test_keyring(object):
# Make sure it is gone
try:
result = kernel_keyring.read_key(TEST_KEY)
- except ValueError, e:
+ except ValueError as e:
assert e.message == 'key %s not found' % TEST_KEY
def test_02(self):
diff --git a/ipatests/test_ipapython/test_ssh.py b/ipatests/test_ipapython/test_ssh.py
index db136a898..913ff8e6b 100644
--- a/ipatests/test_ipapython/test_ssh.py
+++ b/ipatests/test_ipapython/test_ssh.py
@@ -30,7 +30,7 @@ def make_public_key_checker(pk, out):
try:
parsed = ssh.SSHPublicKey(pk)
assert parsed.openssh() == out
- except Exception, e:
+ except Exception as e:
assert type(e) is out
check_public_key.description = "Test SSH public key parsing (%s)" % repr(pk)
return check_public_key
diff --git a/ipatests/test_ipaserver/test_changepw.py b/ipatests/test_ipaserver/test_changepw.py
index 30d7b1dff..1a2f57e8a 100644
--- a/ipatests/test_ipaserver/test_changepw.py
+++ b/ipatests/test_ipaserver/test_changepw.py
@@ -37,7 +37,7 @@ class test_changepw(XMLRPC_test, Unauthorized_HTTP_test):
try:
api.Command['user_add'](uid=testuser, givenname=u'Test', sn=u'User')
api.Command['passwd'](testuser, password=u'old_password')
- except errors.ExecutionError, e:
+ except errors.ExecutionError as e:
raise nose.SkipTest(
'Cannot set up test user: %s' % e
)
diff --git a/ipatests/test_pkcs10/test_pkcs10.py b/ipatests/test_pkcs10/test_pkcs10.py
index c5a1c56b1..86314dfe5 100644
--- a/ipatests/test_pkcs10/test_pkcs10.py
+++ b/ipatests/test_pkcs10/test_pkcs10.py
@@ -111,7 +111,7 @@ class test_update(object):
try:
request = pkcs10.load_certificate_request(csr)
- except NSPRError, nsprerr:
+ except NSPRError as nsprerr:
# (SEC_ERROR_BAD_DER) security library: improperly formatted DER-encoded message.
assert(nsprerr. errno== -8183)
@@ -122,5 +122,5 @@ class test_update(object):
csr = self.read_file("test4.csr")
try:
request = pkcs10.load_certificate_request(csr)
- except TypeError, typeerr:
+ except TypeError as typeerr:
assert(str(typeerr) == 'Incorrect padding')
diff --git a/ipatests/test_webui/ui_driver.py b/ipatests/test_webui/ui_driver.py
index 4b382d8fb..16af5ff16 100644
--- a/ipatests/test_webui/ui_driver.py
+++ b/ipatests/test_webui/ui_driver.py
@@ -144,9 +144,9 @@ class UI_driver(object):
try:
with open(path, 'r') as conf:
self.config = yaml.load(conf)
- except yaml.YAMLError, e:
+ except yaml.YAMLError as e:
raise nose.SkipTest("Invalid Web UI config.\n%s" % e)
- except IOError, e:
+ except IOError as e:
raise nose.SkipTest("Can't load Web UI test config: %s" % e)
else:
self.config = {}
@@ -198,9 +198,9 @@ class UI_driver(object):
driver = webdriver.Remote(
command_executor='http://%s:%d/wd/hub' % (host, port),
desired_capabilities=capabilities)
- except URLError, e:
+ except URLError as e:
raise nose.SkipTest('Error connecting to selenium server: %s' % e)
- except RuntimeError, e:
+ except RuntimeError as e:
raise nose.SkipTest('Error while establishing webdriver: %s' % e)
else:
try:
@@ -213,9 +213,9 @@ class UI_driver(object):
if "ff_profile" in self.config:
fp = webdriver.FirefoxProfile(self.config["ff_profile"])
driver = webdriver.Firefox(fp)
- except URLError, e:
+ except URLError as e:
raise nose.SkipTest('Error connecting to selenium server: %s' % e)
- except RuntimeError, e:
+ except RuntimeError as e:
raise nose.SkipTest('Error while establishing webdriver: %s' % e)
return driver
diff --git a/ipatests/test_xmlrpc/test_sudorule_plugin.py b/ipatests/test_xmlrpc/test_sudorule_plugin.py
index 052578666..f654a94b5 100644
--- a/ipatests/test_xmlrpc/test_sudorule_plugin.py
+++ b/ipatests/test_xmlrpc/test_sudorule_plugin.py
@@ -494,7 +494,7 @@ class test_sudorule(XMLRPC_test):
self.rule_name,
addattr='externalhost=%s' % self.test_invalid_host
)
- except errors.ValidationError, e:
+ except errors.ValidationError as e:
assert unicode(e) == ("invalid 'externalhost': only letters, " +
"numbers, '_', '-' are allowed. " +
"DNS label may not start or end with '-'")
diff --git a/ipatests/test_xmlrpc/xmlrpc_test.py b/ipatests/test_xmlrpc/xmlrpc_test.py
index 808abae19..0db211118 100644
--- a/ipatests/test_xmlrpc/xmlrpc_test.py
+++ b/ipatests/test_xmlrpc/xmlrpc_test.py
@@ -311,7 +311,7 @@ class Declarative(XMLRPC_test):
name = klass.__name__
try:
output = api.Command[cmd](*args, **options)
- except StandardError, e:
+ except StandardError as e:
pass
else:
raise AssertionError(
@@ -334,7 +334,7 @@ class Declarative(XMLRPC_test):
e = None
try:
output = api.Command[cmd](*args, **options)
- except StandardError, e:
+ except StandardError as e:
pass
if not expected(e, output):
raise AssertionError(
diff --git a/ipatests/util.py b/ipatests/util.py
index a8899cc6f..9b6eed7ad 100644
--- a/ipatests/util.py
+++ b/ipatests/util.py
@@ -361,7 +361,7 @@ def raises(exception, callback, *args, **kw):
raised = False
try:
callback(*args, **kw)
- except exception, e:
+ except exception as e:
raised = True
if not raised:
raise ExceptionNotRaised(exception)